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! Request now

Reply
slofish
Regular Visitor

How to sum by distinct values of different column

Hi everybody. This might be a simple calculation, but I'm sort of new to Power BI and need help.

 

I have a table like this, with a batch, part, and batch size. A batch might have several parts, but the Batch Size is always the same.

slofish_0-1717108693200.png

I'm trying to sum the total Batch Size, but I want the sum to only sum distinct values of Batch, something like this:

slofish_2-1717108821476.png

 

How can I calculate a measure with this total in Power BI?

Thanks!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @slofish 

 

You can create several measures as follow:

 

Measure = RIGHT(MAX([Part]), 2)
rank = RANKX(ALLEXCEPT('Table', 'Table'[Batch]), [Measure], , DESC, Dense)
min = MINX(ALLEXCEPT('Table', 'Table'[Batch]), [rank])
sum = CALCULATE(SUM('Table'[Batch Size]), FILTER('Table',[rank] = [min]))

 

Output:

vxuxinyimsft_0-1717119946369.png

 

Best Regards,
Yulia Xu

 

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

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @slofish 

 

You can create several measures as follow:

 

Measure = RIGHT(MAX([Part]), 2)
rank = RANKX(ALLEXCEPT('Table', 'Table'[Batch]), [Measure], , DESC, Dense)
min = MINX(ALLEXCEPT('Table', 'Table'[Batch]), [rank])
sum = CALCULATE(SUM('Table'[Batch Size]), FILTER('Table',[rank] = [min]))

 

Output:

vxuxinyimsft_0-1717119946369.png

 

Best Regards,
Yulia Xu

 

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

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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
Top Kudoed Authors