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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
AB1977
Regular Visitor

Unique Sum DAX

Kia ora

 

The picture below is a snippet of my data set.

Data.PNG

I want to be able to sum the second column based on the data in the first.

I want to sum column 2 for each of the unique sets of data in column 1.

I.e. the sum for 238329 would be 12 and for 238330 would be 12 and so on.

This however is only the start. The actual answer I need is 3 not 12. The second stage is to take the 12 and divide by the count of the 238329's (12/4 in this case).

Hope this is clear. The snip of data above has bben sorted for illustration purposes. The actual data could be in any order and there could be any number of matching data numbers in column 1 rather than the uniform 4 of each show above.

Many thanks in advanc for any help.

1 ACCEPTED SOLUTION
vcastello
Resolver III
Resolver III

Hi AB1977,

 

Assuming your dataset has a table named "Table1" which first column is named "Column1" and second column is named "Column2" ...

1.- Create a new measure called "Total Column2" with the following DAX code: SUM(Table1[Column2]). 
2.- Create a new measure called "Total Column1" with the following DAX code: COUNTA(Table1[Column1]).
3.- Create a new measure called "Total" with the following DAX code: DIVIDE([Total Column2];[Total Column1]).

4.- Create a new visual (table) with Column1 (ID) on rows and each of the measures you've created on columns

That should work

 

Vicente

View solution in original post

3 REPLIES 3
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @AB1977,

 

Could you please mark the proper answer as solution or share the solution if it's convenient for you? That will be a big help to the others.

 

Best Regards!
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
vcastello
Resolver III
Resolver III

Hi AB1977,

 

Assuming your dataset has a table named "Table1" which first column is named "Column1" and second column is named "Column2" ...

1.- Create a new measure called "Total Column2" with the following DAX code: SUM(Table1[Column2]). 
2.- Create a new measure called "Total Column1" with the following DAX code: COUNTA(Table1[Column1]).
3.- Create a new measure called "Total" with the following DAX code: DIVIDE([Total Column2];[Total Column1]).

4.- Create a new visual (table) with Column1 (ID) on rows and each of the measures you've created on columns

That should work

 

Vicente

Or, since the function described is essentially an average, create a measure AverageC2 = AVERAGE(Table1[Column2]) and create a visual with Column 1 in the first column and this measure in the second.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.