Forum Discussion
Convert Tableau LOD Nested Fixed function to Power BI DAX
Need help with replicating a Nested 'FIXED' Level of detail expression in Tableau to DAX-
Top Duration(mins) = { FIXED [Device]:MAX(
{ FIXED [Device],[Reason]:SUM(IF [State]='Off' THEN [Duration(mins)] END)})}
Basically find the maximum Duration and corresponding Reason for every Device when State = Off.
| Sample Data | |||
| Mfg plant | Device | Reason | Duration (mins) |
| TX | L1 | Waiting | 10 |
| TX | L1 | Waiting for pickup | 20 |
| TX | L1 | Line Change | 30 |
| TX | L2 | Filler | 40 |
| TX | L2 | Line Change | 50 |
| TX | L3 | Waiting | 60 |
| TX | L3 | Problem with line | 70 |
| TX | L4 | Cleanup | 80 |
| TX | L4 | Problem with line | 90 |
| TX | L4 | Waiting for pickup | 100 |
| Expected Results | |||
| Mfg Plant | Device | Top Reason | Top Duration(mins) |
| TX | L1 | Line Change | 30 |
| TX | L2 | Line Change | 50 |
| TX | L3 | Problem with Line | 70 |
| TX | L4 | Waiting for pickup | 100 |
6 Replies
- Greg_DecklerCommunity Champion
Anonymous I don't see [State] in your data but best guess would be one of these two variants:
Top Duration(mins) = MAXX(FILTER('Table',[State]="Off"),[Duration(mins)] or Top Duration(mins) = CALCULATE(MAX('Table'[Duration(mins)]),'Table'[State]="Off")- AnonymousNot applicable
Greg_Deckler Sorry, should have mentioned that the lowest level of detail in the data is a key value (Event_key). So we need to do a SQL 'group by' kind of DAX measure that SUMS up Duration for every Device & Reason and then gets the MAX for a each Device. I've tried ALLEXCEPT and SUMMARIZE but cant get it to work.
- AllisonKennedyCommunity Champion
Anonymous Have you tried adding a new column to your table with my suggestion? Your latest reply says you need to SUM duration? What does the original raw data actually look like? From your sample there is no summing required. If you have more granular rows than you have posted, my measure can be adapted, but we need all the info please.
- AllisonKennedyCommunity Champion
Anonymous I am assuming you also have a [State] column in your data?
One option is to do this as a new column:
LastDuration =
IF(COUNTROWS(FILTER('Table', 'Table'[Duration] >=EARLIER('Table'[Duration]) && 'Table'[State] = "Off" && 'Table'[Device] = EARLIER('Table'[Device]))) = 1, 1, 0)Then use that as a filter in your visuals. - v-deddai1-msftCommunity Support
Hi Anonymous ,
Just based on the sample data you have provided, you can use the following calculated table:
Table 2 = SUMMARIZE('Table','Table'[Mfg plant],'Table'[Device],"Top Reason",CALCULATE(MAX('Table'[Reason]),FILTER('Table','Table'[Duration (mins)] = MAX('Table'[Duration (mins)]))),"Top Duration(mins)",MAX('Table'[Duration (mins)]))Would you please explain more about [State] column or provide raw data for accurate help.
Best Regards,
Dedmon Dai
- v-deddai1-msftCommunity Support
Hi Anonymous ,
Is there any update?
Best Regards,
Dedmon Dai