cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper III
Helper III

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

Accepted Solutions
Highlighted
Super User IV
Super User IV

Re: Sum of Max values

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
Highlighted
Super User IV
Super User IV

Re: Sum of Max values

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

Highlighted
Super User IV
Super User IV

Re: Sum of Max values

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


---------------------------------------

Putting square pegs in round holes since 1972.

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Highlighted
Helper III
Helper III

Re: Sum of Max values

Thanks Ashish,

 

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

Highlighted
Super User IV
Super User IV

Re: Sum of Max values

You are welcome.


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

Helpful resources

Announcements
Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Power Platform 2020 release wave 2 plan

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors