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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
GinjaNinja29
New Member

How to sum column based on distinct values from another

Hello - these are samples of the relevant information in the table for which I am attempting to sum the quantity, based on the unique ID.

 

If the ID is found in the table more than once, I only need one line where the Quantity is summed.  Since I will be using this to calculate averages as well, it would be ideal if the result column simply displayed a blank (instead of 0) for the Result.

 

Thank You!

 

Original Table:

IDQuantity
11
12
14
21
37
33
25

 

 

Calculated Measure:

IDQuantity
17
26
310

 

1 ACCEPTED SOLUTION

Hi , @GinjaNinja29 

You may need to create calculated columns as below:

Count 1 = CALCULATE(COUNT('Original Table'[ID]),ALLEXCEPT('Original Table','Original Table'[ID]))
Quantity1 = IF('Original Table'[Count 1]>1,'Original Table'[Quantity],BLANK())

The result will show as below:

14.png

 

 

You also can try to create measure like this:

Quantity 2 = 
var a= COUNT('Original Table'[ID])
return IF(a>1,CALCULATE(SUM('Original Table'[Quantity])),BLANK())

In table visual , make sure the  fileld "id" show items with no data

15.png

 

Here is a sample.

pbix attached 

 

Best Regards,
Community Support Team _ Eason
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

4 REPLIES 4
jwessel
Helper II
Helper II

Based on the table supplied with ID and Quantity, what would be the way to just obtain the maximum quantity value for each ID in a vis ?  (PowerBI newby here) 😁

amitchandak
Super User
Super User

@GinjaNinja29 ,

For Avg you do not need to that, You can so like Avg of sum

 

AverageX(summarize(Table,Table[ID],"_1",sum(Table[Quantity])),[_1])

or
AverageX(values(Table[ID]),sum(Table[Quantity]))

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you - I should be more clear.

 

In one of my visuals, I will be also using this field to count is not blank. 

 

This field will be used to count (is not blank), Sum, Average, and count if >3

Hi , @GinjaNinja29 

You may need to create calculated columns as below:

Count 1 = CALCULATE(COUNT('Original Table'[ID]),ALLEXCEPT('Original Table','Original Table'[ID]))
Quantity1 = IF('Original Table'[Count 1]>1,'Original Table'[Quantity],BLANK())

The result will show as below:

14.png

 

 

You also can try to create measure like this:

Quantity 2 = 
var a= COUNT('Original Table'[ID])
return IF(a>1,CALCULATE(SUM('Original Table'[Quantity])),BLANK())

In table visual , make sure the  fileld "id" show items with no data

15.png

 

Here is a sample.

pbix attached 

 

Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.