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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Sum the value and find max

Hello All,

 

I have a table as below.

OrderPartQTYYearDateBuyer
A00112345120201920190102ABC
A0011234550201920190212ABC
A0021234570201920190315DEF
A0011234650201920190115ABC
A0011234650201920190210ABC
A00312346150201920190312XYZ
A0031234650201920190210XYZ

 

I would like to see the Part number and Buyer for the Max Quantity(sum of rows for the Part number if multiple rows).

In short it should be 

Part      Buyer

12345   ABC - AS that buyer has max qty 120+50

12346   XYZ  

 

Thanks

 

2 ACCEPTED SOLUTIONS
Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

Please check the below for creating a measure.

 

Buyer Measure =
IF (
ISFILTERED ( 'Table'[Part] ),
MAXX (
FILTER (
SUMMARIZE ( 'Table', 'Table'[Buyer], "@qtytotal", SUM ( 'Table'[QTY] ) ),
[@qtytotal]
= MAXX (
GROUPBY (
'Table',
'Table'[Buyer],
"@qty", SUMX ( CURRENTGROUP (), 'Table'[QTY] )
),
[@qty]
)
),
'Table'[Buyer]
)
)

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

CNENFRNL
Community Champion
Community Champion

Buyer Max = 
MAXX( TOPN( 1, DISTINCT( Sales[Buyer] ), CALCULATE( SUM( Sales[QTY] ) ) ), Sales[Buyer] )

bonus

Buyer Min = 
MAXX( TOPN( 1, DISTINCT( Sales[Buyer] ), CALCULATE( SUM( Sales[QTY] ) ), 1 ), Sales[Buyer] )

Screenshot 2021-06-10 112345.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!

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

@CNENFRNL @Jihwan_Kim Thanks for your help.Both of them worked and its just that i had to learn few things before putting them to use.

v-henryk-mstf
Community Support
Community Support

Hi @Anonymous ,

 

For the solution provided by @Jihwan_Kim , I did a test. Can also get the desired result.

v-henryk-mstf_0-1623662787079.png

 


Best Regards,
Henry

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

CNENFRNL
Community Champion
Community Champion

Buyer Max = 
MAXX( TOPN( 1, DISTINCT( Sales[Buyer] ), CALCULATE( SUM( Sales[QTY] ) ) ), Sales[Buyer] )

bonus

Buyer Min = 
MAXX( TOPN( 1, DISTINCT( Sales[Buyer] ), CALCULATE( SUM( Sales[QTY] ) ), 1 ), Sales[Buyer] )

Screenshot 2021-06-10 112345.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!

Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

Please check the below for creating a measure.

 

Buyer Measure =
IF (
ISFILTERED ( 'Table'[Part] ),
MAXX (
FILTER (
SUMMARIZE ( 'Table', 'Table'[Buyer], "@qtytotal", SUM ( 'Table'[QTY] ) ),
[@qtytotal]
= MAXX (
GROUPBY (
'Table',
'Table'[Buyer],
"@qty", SUMX ( CURRENTGROUP (), 'Table'[QTY] )
),
[@qty]
)
),
'Table'[Buyer]
)
)

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors