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
RustyNails
Helper III
Helper III

Total Sum of Max by each category

Hello, I need help with something I'm stuck on. I'm looking to sum the total max values of each category that itself is a summation.

 

Here's my sample table: It has four columns, order_cd, part, cost_type and rate. NOTE: Sum of Part and Max of Order_cd are my measures. Also please keep in mind that we dont have only 3 different cost_types. This is just a sample. Real data will have hundreds of orders, hundreds of parts, thousands of cost types with their own rates.

 

Order_CdPartcost_typerateSum of PartMax of Order_Cd
A0001Steel BoltMetal      625          13,817                     13,817
A0001Steel BoltWelding   3,750          13,817                     13,817
A0001Steel BoltPackaging   9,442          13,817                     13,817
A0001Iron CaseMetal      441            9,753                     13,817
A0001Iron CaseWelding   2,647            9,753                     13,817
A0001Iron CasePackaging   6,665            9,753                     13,817
B0002Metallic FrameMetal      417            9,211                        9,753
B0002Metallic FrameWelding   2,500            9,211                        9,753
B0002Metallic FramePackaging   6,294            9,211                        9,753
B0002Iron CaseMetal      441            9,753                        9,753
B0002Iron CaseWelding   2,647            9,753                        9,753
B0002Iron CasePackaging   6,665            9,753                        9,753
  Total_measure                       23,570

 

What I want to do first is get a Totals of each Part (Sum of Part), which I did, and then to get Max of Order Cd:

 

Max of Order Cd =
var v1 = MAXX(SUMMARIZE('Table','Table'[Order_Cd],'Table'[Part],"amount",SUM('Table'[rate])),[amount])
return v1

 

This gets me almost where I need to be:

 

Order_cdMax of Order_cd
A0001     13,817
B0002     9,753

 

All I want to do now is Sum the Max of Order_cd, which is where I'm stuck. I have:

 

Total_measure

= SUMX(SUMMARIZE('Table','Table'[Order_Cd],"max of sum",v1),[max of sum])
 
But this is summing it incorrectly. Please let me know what i'm missing, thank you!
1 ACCEPTED SOLUTION

@RustyNails 
I used the following two measures, hope it helps you.

 

Sum of Part = CALCULATE(SUM('Table'[rate]),ALLEXCEPT('Table','Table'[Part],'Table'[Order_Cd]))


Total measure =
SUMX (
    SUMMARIZE (
        'Table',
        'Table'[Order_Cd],
        "sum of part", [Sum of Part],
        "max of order cd", CALCULATE (
            MAXX ( 'Table', [Sum of Part] ),
            ALLEXCEPT ( 'Table', 'Table'[Order_Cd] )
        )
    ),
    CALCULATE (
        MAXX ( 'Table', [Sum of Part] ),
        ALLEXCEPT ( 'Table', 'Table'[Order_Cd] )
    )
)

 

 summax.JPG

Paul Zheng
Don't forget to hit THUMBS UP and mark it as a solution if it helps you!

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

I am not sure why are u using v1

Try

Total_measure
= SUMX(SUMMARIZE('Table','Table'[Order_Cd],"max of sum",[Max of Order Cd]),[max of sum])

Total_measure
= SUMX('Table',,[Max of Order Cd])

Hello, I tried both the total_measure measures,

 

the first one gives total of : 27,634

the second one gives total of : 165,804

 

I need them to add up to 23,570

@RustyNails 
I used the following two measures, hope it helps you.

 

Sum of Part = CALCULATE(SUM('Table'[rate]),ALLEXCEPT('Table','Table'[Part],'Table'[Order_Cd]))


Total measure =
SUMX (
    SUMMARIZE (
        'Table',
        'Table'[Order_Cd],
        "sum of part", [Sum of Part],
        "max of order cd", CALCULATE (
            MAXX ( 'Table', [Sum of Part] ),
            ALLEXCEPT ( 'Table', 'Table'[Order_Cd] )
        )
    ),
    CALCULATE (
        MAXX ( 'Table', [Sum of Part] ),
        ALLEXCEPT ( 'Table', 'Table'[Order_Cd] )
    )
)

 

 summax.JPG

Paul Zheng
Don't forget to hit THUMBS UP and mark it as a solution if it helps you!

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.