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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
khush19
Resolver I
Resolver I

Sum of Max values

Hi,

 

I have below table ,note it is just the smaple data

 

 

I want to calculate SUM on top of MAX.

Max is calculated on grouping CustomerID,AreaID and date,and once max is calulated need to sum of data based on CUstomerID and Date.

 

CustomerIDAreaIDDateAmountMax AmountSUM Amount
1x6/04/2020101040
1y6/04/2020203040
1y6/04/2020303040
1x5/04/2020102020
1x5/04/2020202020
2u6/04/2020102050
2z6/04/202053050
2u6/04/2020202050
2z6/04/2020303050
2z6/04/2020153050

 

in my reports I will have card which will display Total Amount for a day for a customer.

 

So if CustomerID=1 and date is 6/04/2020 then card should display 40

if CustomerID=1 and date is 5/04/2020 then card should display 20

if CustomerID=2 and date is 6/04/2020 then card should display 50

 

I am able to calculate MAX,below is my measure:

MaxAmount =
CALCULATE(MAX(RealReport[Amount]),ALLEXCEPT(RealReport,RealReport[CustomerID],RealReport[AreaID],RealReport[Date]))
 
I tried to calculate SUM,but it is not coming as expected:
 
TotalCalculatedAmount =
SUMX(ALLEXCEPT(RealReport,RealReport[CustomerID],RealReport[Date]),[MaxAmount])
 
I also tried :
Measure =
SUMX
(SUMMARIZE(RealReport,RealReport[CustomerID],RealReport[Date],"Max Amount",CALCULATE(MAX(RealReport[Amount]),ALLEXCEPT(RealReport,RealReport[CustomerID],RealReport[date],RealReport[AreaID]))),[Max Amount])
 
How to get sum?
 
 
 
1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

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


Follow on LinkedIn
@ 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...
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks Ashish,

 

I never thought measures you created will work as it looks so neat and simple,it was great learning

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

July Newsletter

Fabric Community Update - July 2024

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