Lookup Values in Power Pivot tables with DAX - excel

i am trying to create a calculated column in Excel which should contain values from related tables. I tried looking into the Lookup function but this looks too complicated for my knowledge.
I have an Incident table where i want to have a calculated Column named closdBy. In this column i want to put the name of the operator that closed the incident. Every incident has many mutation entries which are stored in a Mutations table. This Mutations table has 1 statusID which comes from another related table named Status
In the calculated Field closedBy i want the calculated column to display the Name of the operator whose name matches the statusID Closed The name of the operator comes from the Operator table.
Anyone can help me with this ? Would appreciate it a lot.
POWER BI Example: https://ufile.io/z0g4x
Excel Example: https://ufile.io/6adju

required result in incident table (download PowerBI file) :
I have made some modification in relationship between table incident and mutation
created a column in mutation table
ID_Closed = IF(Mutation[statusID]="{CLO}",Mutation[ID],CONCATENATE(Mutation[ID],Mutation[statusID]))
Hoping this will help!

This is how my table looks like. The mutation table can have the same value for status (see {CLO} but I want to have the field Closed By and Resolved by in the Incident table to display the most recent Operator.
I have here an adjusted PowerBi file with more data:
https://ufile.io/20u0v

Related

PowerBI: Comparing a filterd table against a variable string is returning an empty table

Please see the code below for a Power BI table in DAX:
TABLE1 =
VAR ParticipantOneParticipantId =
SELECTEDVALUE(
ParticipantOneDetails[ParticipantId]
)
RETURN
FILTER(
ParticipantOneMeetings,
ParticipantOneMeetings[ParticipantId] = ParticipantOneParticipantId
)
I am fetching a value for ParticipantId from a sliced table called ParticipantOneDetails and setting ParticipantOneParticipantId to it.
In the next step I am trying to filter the table ParticipantOneMeetings based on its column ParticipantId comparing it against ParticipantOneParticipantId.
The problem is that the resulting table is coming out empty even though I know that ParticipantOneParticipantId must have a value and the ParticipantOneMeetings table also has values. I verified by comparing against a hard-coded string.
Can you please point out what I am doing wrong? Is comparing this way not legal?
The problem lies in the process you are trying. A calculated/custom tables and columns are static. They always refresh when the data set is refreshed. They do not interact dynamically with the slicer value. So it is impossible to get data from a slicer dynamically for a Custom Table generation.
Now, your requirement of creating a new table based on slicer value is not completely clear to me. As what you are trying, is a simple filtered output of your table "ParticipantOneMeetings" after applying the Slicer. If you have relation between your 2 tables using column "ParticipantId", change in Slicer will automatically filter out values in ParticipantOneMeetings table. Why you wants to hold this same filtered values in a new Custom table is really a mater here to know for finding appropriate solution for you.
Turns out I needed to add the following measure to the table output:
MeetingsAttendedByBothParticipants =
countrows(
INTERSECT(
VALUES(ParticipantOneMeetings[Name]),
VALUES(ParticipantTwoMeetings[Name])
)
)
The above provides an intersection on output of two sliced meeting tables. This results in a list of meetings that both persons attend.

How to use the unique items from in a column from several tables as the row criteria of a pivot table in excel data model using Dax?

I have 3 different tables with the customer name and there are duplicates as well as unique customers in the 3 tables and I need to get the unique for all 3 to be used as the rows criteria in the pivot table.
I've been finding a way to do so but I cannot seem to figure it out.
The measure I tried is: Customers:=DISTINCT(UNION(VALUES('Test1 - Invoice'[CustomerID]),VALUES('Test2 - Invoice'[CustomerID]),VALUES('Test3 - Invoice'[CustomerID])))
But I get the error below:
Semantic Error: Too many arguments were passed to the VALUES function.
The maximum argument count for the function is 1.
I am quite new to DAX and have no idea how to do it. I believe it is because measures are only for values if i'm not mistaken
I read that to place on other fields of the pivot table, it has to be a calculated column although I do not see how it can be a calculated column as well.
One approach is to create a separate table to store the Customer Name dimension - then create relationships between that Customer dimension table and your 3 fact tables. This would be most effective at the Power Query stage, but can be done using DAX.
An alternative is to merge your 3 fact tables - again, this would be best done with Power Query, but is possible with DAX.

How to create a many-many relationship in Excel's data model?

We have an issue with power BI where we cannot use a many-many relationship to do calculations.
End goal is Column E:
Initial Table #1:
Initial Table #2:
When I use the Average Price per Area of Initial Table #2 on the Initial Table #1[Item] as the Rows element, I will get a warning: Relationships between tables maybe needed. But the issue is Power Bi in Excel does not support a many-many relationship yet.
As can be seen, the Pivot Table is not displaying correctly as there is no item green. I have another database with more SKUs and it's all displaying #NUM there because it cannot reference the items despite having the same name.
Create a third table that contains unique items, i.e,
Table 3:
Column "Item"
Blue
Green
Red
...
Then connect both initial tables to it using field "Item".
Put "Item" from the third table on pivot rows, and your report should work (assuming your DAX formulas are correctly written).

How to add calculated column to a pivot table connected to SSAS tabular model?

Or in another words the question is - how to add some calculation in the pivot table based on columns which do not exist in model level.
I've reproduced my problem using AdventureWorksDW2014 sample database.
Let's say I want to calculate difference between Actual and Budget scenario amounts in the FactFinance table for each Organisation and present it in a form of pivot table.
To achieve that I've created a simple model (screen above) and added SumOfAmount measure to the FactFinance table SumOfAmount:=SUM([Amount])
Next, I've opened my model in Excel and created very simple pivot table (shown below)
So, (the question part) now I want to add an extra column to my pivot table, which should calculate something (for example difference) between columns Actual and Budget. And I want this new column been a part of the pivot table so I could filter it or\and add new grouping levels without necessity to change something "outside" the pivot table.
TRIED SO FAR
I tried to add Calculated Field but it seems like I can only use "real" columns for calculations. Columns which appeared in a pivot table based on values from COLUMNS quadrant can't be used as sources for calculations.
FINAL SOLUTION
I got it finally combined two pivot tables: the old one and the one with Diff measure, defined as Diff:=[Actual Amount]-[Budget Amount], where
Actual Amount:=Calculate([SumOfAmount];'DimScenario'[ScenarioName] = "Actual")
Budget Amount:=Calculate([SumOfAmount];'DimScenario'[ScenarioName] = "Budget")
as #WimV suggested
First calculated measure is good:
SumOfAmount:=SUM('FactFinance'[Amount])
Add the following Calculated measures (if needed mark as hidden):
Budget Amount:=Calculate([SumOfAmount],'DimScenario'[Scenariokey] = "Budget")
Actual Amount:=Calculate([SumOfAmount],'DimScenario'[Scenariokey] = "Actual")
You can use the new calculations for example in a difference calculations

How to calculate number of rows in a 1-to-many relationship in PowerPivot

I'm trying to do what I thought was a relatively simple calculation between 2 tables I have in the new PowerPivot add-on for Excel 2010.
My 2 tables loaded at setup as follows:
Table 1:
FooID, BarID, Name
Table 2:
BarID, Date
There is a 1 to many relationship between Table 1 and 2.
I want to add a calculated column to Table 1 that just does a sum of all the rows in Table 2.
I've tried this with no luck. The calculation results in null in every column. Excel isn't reporting an error, so it's not that the calculation is invalid, it's just doing somethign I"m not understanding.
=CALCULATE(COUNTROWS(Table2), Filter(Table2, Table2[BARID] = Table1[BARID]))
I also tried something simpler that I thought would also work:
=COUNTROWS(RELATEDTABLE(Table2))
However that also results in null.
I have made sure that table 1 and table 2 have a relationship on BARID.
=COUNTROWS(RELATEDTABLE(Table2)) is the correct formula if there is an existing relationship.
Might it be that there simply are no matching keys?
You can try that by using your first formula and matching an explicit value eg.:
=CALCULATE(COUNTROWS(Table2), Filter(Table2, Table2[BARID] = "SomeBARIDFromTable2"))
The above formula works on tables regardless of wheter a relationship is defined.
HTH,
Hrvoje

Resources