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

How to get the max value of quarterly sum with a measure?

I have the below data. 

Fiscal YearFiscal QtrqtdTotal QTDMax QTD
2020Q11010040
2020Q22010040
2020Q33010040
2020Q44010040
2021Q158035
2021Q2158035
2021Q3258035
2021Q4358035

 

I am trying to achieve the last two columns in the above table with two measures.

The qtd field is the raw data. I got the [Total QTD] to populate correctly with the measure.

[Total QTD] = CALCULATE(SUM('Table'[qtd]),ALL('Date'),VALUES('Date'[Fiscal Year]))

This shows the sum of qtd value for the year, for all quarters.

Similarly, I am trying to get the Max of qtd, by replacing the sum with 'max' in the same formula but it doesn't work. 

Can someone please tell me how to get this?

Thank you very much in advance.

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@Anonymous This looks like a measure aggregation problem. See my blog article about that here: https://community.powerbi.com/t5/Community-Blog/Design-Pattern-Groups-and-Super-Groups/ba-p/138149

The pattern is:
MinScoreMeasure = MINX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
MaxScoreMeasure = MAXX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
AvgScoreMeasure = AVERAGEX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
etc.


@ 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

5 REPLIES 5
CNENFRNL
Community Champion
Community Champion

@Anonymous , you may want to try measures,

Total QTD = CALCULATE ( SUM ( Sales[qtd] ), ALLEXCEPT ( Sales, Sales[Fiscal Year] ) )
Max QTD = 
MAXX (
    CALCULATETABLE ( Sales, ALLEXCEPT ( Sales, Sales[Fiscal Year] ) ),
    Sales[qtd]
)

Screenshot 2021-02-17 202920.png


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
Not applicable

@CNENFRNL Thank you for your response.

I tried your Max QTD measure but it's not returning the right values for me.

I need the Max QTD to get poulated with 2020 Q4 value = 40 for all 2020.

Please notice that the 40 is a sum() several different values, for example 20+10+10. The measure is populating Max QTD with 20. Beacuse 20 Is the max value for that quarter.

But I want it to take the sum of 2020 Q4 which is 40. and show it in the Max QTD.

 

Could you please help me acieve this?

Thanks in advance.

 

Greg_Deckler
Super User
Super User

@Anonymous This looks like a measure aggregation problem. See my blog article about that here: https://community.powerbi.com/t5/Community-Blog/Design-Pattern-Groups-and-Super-Groups/ba-p/138149

The pattern is:
MinScoreMeasure = MINX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
MaxScoreMeasure = MAXX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
AvgScoreMeasure = AVERAGEX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
etc.


@ 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 I tried it with your second (A slightly more complex solution), making some small changes to it, and it worked.

Thank you very much 🙂

 

Anonymous
Not applicable

@Greg_Deckler I tried the solution from your post but it's still not working.
I need the Max QTD to show the MAX value of 'QTD' field which is a SUM(qtd) with Fiscal Year and Quarter filters.

Thank you for your response.

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.