Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello! I had previously asked this question which I would like to expand on.
If we imagine the following scenario: I am responsible for the output of a chocolate factory with three machines. I am measuring the output of these three machines on a daily basis. In my previous question (linked above) I am able to see the combined average daily production of these three machines (i.e. I can see the total output of the factory on a given day, and the average output for a custom date range):
averagex(summarize(Table[Date],"_Sum",sum(Table[Factory Output])),[_Sum])
However, in a seperate measure, I would now like to see the last date since production (i.e. combining all three machines) was zero. This could indicate the last date when there was a power outage and all machines stop producing for example. I have tried it in the following way:
CALCULATE(max('Table'[DATE]), filter('Table',sumx(summarize('Table', 'Table'[DATE],"_Sum",sum('Table'[Machine Output])),[_Sum])=0))
However, this measure returns the last date when either of the three machines stopped producing NOT when all three of them have stopped producing.
I imagine this is something to do with the context in which the measures are evaluated but I am unsure how to proceed. Any help would be much appreciated!
Solved! Go to Solution.
@Anonymous I plugged my measure formula in and got 12/31/2020 See attached PBIX below sig.
Measure =
VAR __Table = SUMMARIZE('Table',[DATE],"Count",COUNTROWS(FILTER('Table',[Machine Output]=0)))
RETURN
MAXX(FILTER(__Table,[Count]=3),[DATE])
@Anonymous Frankly speaking, I didn't see the point forcing SUMMARIZE into the calculation; I hope this measure works
Latest Non-Work Date =
MAXX (
FILTER (
FILTER ( ALL ( 'Table'[Date] ), 'Table'[Date] <= MAX ( 'Table'[Date] ) ),
CALCULATE ( SUM ( 'Table'[Machine Output] ) ) = 0
),
'Table'[Date]
)
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
@Anonymous , Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.
You can try this in between
CALCULATE(max('Table'[DATE]), filter('Table',sumx(summarize('Table', 'Table'[DATE],"_Sum",sum('Table'[Machine Output])+0),[_Sum])=0))
Hi @amitchandak @Greg_Deckler thank you for your answers, however they both seem to return blank or the incorrect date. Please see an example pbix
@Anonymous I plugged my measure formula in and got 12/31/2020 See attached PBIX below sig.
Measure =
VAR __Table = SUMMARIZE('Table',[DATE],"Count",COUNTROWS(FILTER('Table',[Machine Output]=0)))
RETURN
MAXX(FILTER(__Table,[Count]=3),[DATE])
@Anonymous Maybe:
Measure =
VAR __Table = SUMMARIZE('Table',[DATE],"Count",COUNTROWS(FILTER('Table',[Machine Output]=0)))
RETURN
MAXX(__Table,[DATE])
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
114 | |
100 | |
81 | |
70 | |
62 |
User | Count |
---|---|
148 | |
116 | |
104 | |
90 | |
65 |