Line value in the chart is not working property - powerbi

I'm trying to make a line and stacked column chart like this:
The problem is that the values of my database doesn't match with the line
values.
My chart have 2 levels in the hierarchy, one of Departments and another of
Subdepartments. The line value is the objetive of each subdepartment and
columns are the quatity of occupational accident by each subdepartment.
Considering this I have 3 tables:
OPS, this table contains the quantity of occupational accident
DEPARTMENTS, this table contains subdepartments and departments
OBJETIVES, this table contains the objetive by subdepartment (This table was created by myself in Excel)
This is my Departments table where ID is the subdepartmentID(as "Nombre" in my table) and DepartamentoPadreID is the Department that have another subdepartments. E.G.
The ID 113 that is Petronor contains another departments as 114= Economico Financiera, 115= Fiabilidad y Mantenimiento and so on that's why departments 114 and 115 are subdepartments inside Petronor (113) and the subdepartment Economico Financiera(114) what is subdepartments from Petronor contains another departments.
This is the relationship beetween my tables:
My Departments table is joined with OPS by the ID and it has many relations with OPS because we distinguish beetween
IDDepartment
ID from observed department
ID from observer department
The table below contains the objetive by each of subdepartment:
And this is my chart by subdepartments:
As you can see i didn't put any blank or null value in my table and my chart is taking blanks values.
Someone know what's the error? It's weird because i did the same with another 3 tables and i don't have any error.

Related

PowerBi Join column value strings together in each row

I have a table like shown below titled Employees:
Name LOC1 LOC2 LOC3 LOC4
-----------------------------------------
Joe DAY CVG DTW
Jane PVD STL
John LAX SAN SFO ANC
I created a measure to combine the LOC fields into 1 result separated by a space. I keep getting errors because PBi wants to aggregate the data fields. All fields are type Text. I've tried all the usual combine methods, below are a couple of examples...
CombineLOCs=CONCATENATE('Employees'[LOC1],'Employees'[LOC2])
CombineLOCs= 'Employees'[LOC1] & " " & 'Employees"[LOC2]
This is what I get back:
"A single value for column 'LOC1' in table 'Employees' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation....etc."
I ultimately have a table visual on my canvas and instead of listing out all of the columns on that table, I just want 1 column with all of the combined LOC values for each employee in it.
If you just want a single column where the LOC columns are joined together, then you need to create a new column within the table, rather than a new measure. A measure expects you to aggregate the values. A column will concatenate the text strings on a row by row basis.
If you select the new column option, either on the table tools or the fields sidebar, then use the concatenate formula in your question, that should work.
With the new column, you can then include the employee name and the associated LOC values.

No data in related table - artificial blank category DAX

I have following questions.
Table Sales:
Table Product:
Table Sales is connected to table Product via Sales ID.
Table Sales contain 5 unique records, table Product contain only 3 of them. 2 are missing. Is there some way how to artificially create in Power BI missing category?

Lookup value with multiple scenario in Power Bi

I have a two tables are Data and Report.
Data Table:
In Data table contain two columns are item and supplier code. The item column contain text & number and supplier code column contain as a text.
Summary if CHE record in DATA:
if any of the items have CHE records in the data table, get the values if only one CHE record, and if there is more than one CHE record then compare each column (length and Supplier) and if any of the columns has different value then return MIXED otherwise return Actual value
Summary if no CHE record
if only one none CHE record in the data table then returns the actual values but if more than one none CHE records in the data table for that time, compare the values of each column, and if any column value is different then return MIXED otherwise value.
Summary: no record found in DATA table:
Return N/A
Logic
My first priority is “CHE” and second priority is “KKR” in order get the length and supplier from Data table into the Report Table.
Scenario 1;
If two different supplier {“CHE” & “KKR”} for the same item in data table then I would like to get the data (length and supplier) against “CHE” in report table according to the item. (Please refer the item 123 and 5678 in both tables ”Data” and “Report”)
Scenario 2;
If supplier not repeated according to the item and the item contain either any of these supplier {“CHE” or “KKR”} in data table, in these scenario pull the data (length and supplier) against the item in report table based on the availability in data table. (Please refer the item 5555, 6666, 9876 and 2345 in both tables ”Data” and “Report”)
Scenario 3;
If supplier not repeated according to the item and the item contain either any of these supplier {“CHE” or “KKR”} but the length & supplier are different in data table in these scenario return as a text “Mixed” were belongs to (column; either length or supplier or both) in report table according to the item. (Please refer the item 123456 and 567 in both tables ”Data” and “Report”)
Scenario 4;
If two different supplier {“CHE” & “KKR”} for the same item in data table but the length and supplier are variable in data table in this scenario return as a text “Mixed” were belongs to (column; either length or supplier or both) in report table according to the item. (Please refer the item 116 in both tables ”Data” and “Report”)
Scenario 5;
If records not found in date table the return as “NA” in report table according to the item. (Please refer the items in report in table 4444, 12 and 10)
I am looking for calculated column option in order to achieve my result.
Current logic
I created New table for order for supplier priority
I created two helper column for running count and unique count
Finally I am applying the following calculated column in report table
LENGTH = LOOKUPVALUE(
DATA[Length],
DATA[ITEM],REPORT[ITEM],
DATA[UNIQUE_COUNT],1,"NA")
it almost working fine but it will give a wrong result (item 123456 and 567) were my desired is "Mixed" in report table. I highlighted in red and green snapshot for your reference.
My final result look like this
Herewith attached the PowerBi file for your reference https://www.dropbox.com/s/p81uy12tfh1htwu/AUOM1.pbix?dl=0
Can you please advise.
It's not entirely clear what you're trying to do but I think this measure pattern may help you:
IF (
DISTINCTCOUNT ( DATA[SUPPLIER] ) > 1,
"MIXED",
SELECTEDVALUE ( DATA[SUPPLIER], "NA" )
)
For more than one value, you get MIXED. For one value, you get that single value. For no values, you get NA.

Power BI How to Sum Matched 2 Columns

I have two tables. First one represents sales values of company by department, product ID and month. Second table contains sales target by department and month. I want to add a column to second table. It should shows sum of values from table 1 with grouping department and month.
For Example:
For 310101 in Februray sum of values is 110. So, the first row of table 2 should be 110.
Can you please help me with this DAX function?
Create a calculated column in both tables which will represent an unique ID (Eg: ID = Table1[Dpt ID] & Table1[Month]) and join the both tables by this ID field to create a relationship between these 2 tables.
Now, select all the columns from Table 2 and also select Value column from Table 1. You should get the sum by department.

Create table comparing Two Queries with identical fields/field names

I would like to create a table to compare Month To Date (MTD) Vs YTD Sales data metrics
I am using two queries:
1st query = YTD Sales data (Two fields: Sales and Quotes)
2nd query = MTD Sales Data (Two Fields: Sales and Quotes).
Each query has the same field names, just different data
I would like to output a table like the following
How to I create the above table? At the moment I can only create a table like the following:
The latter 1x4 table only works if I appropriately name the fields. But definitely isn’t what I want, because with enough fields, the table could go on forever.
Any help would be appreciated
In the query editor, create a label column for each table that labels what they are and then append the two tables together so you get something like this:
Then you can create a matrix visual with the Label column in the Columns field and the Sales and Quantity columns in the Values area.
Make sure you've switched "Show on Rows" to "On" under the Format > Values section of the Visualizations pane.