Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
Anonymous
Not applicable

Seeing last day of zero production based on SUMMARIZE

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!

1 ACCEPTED 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])

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

6 REPLIES 6
CNENFRNL
Community Champion
Community Champion

@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!

amitchandak
Super User
Super User

@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))

Anonymous
Not applicable

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])

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler you were right, thank you!

Greg_Deckler
Super User
Super User

@Anonymous Maybe:

Measure = 
  VAR __Table = SUMMARIZE('Table',[DATE],"Count",COUNTROWS(FILTER('Table',[Machine Output]=0)))
RETURN
  MAXX(__Table,[DATE])

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.