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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors