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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Sum of Value filtering Unique Rows

I have a column that I had to split which equated to more rows. I currently use the Distinct Count from the ID row for most count based visuals.

 

I need to get the sum of certain columns but I dont want it to add every row.

 

IDMaterial Used
1100
1100
1100
2380
3421
3421
4100

 

This should only equal 1001. As you can see, the sum of unique values in the materials column wouldnt work since values may match. The ID column needs to be referenced as the control column.

1 REPLY 1
Jimmy801
Community Champion
Community Champion

Hello @Anonymous 

 

I don't know how you want to show it. In my code i take your table, and make a sum of a distincted table and show only the result of that

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTI0MFCK1cHNNgKyjS0gbGMg28TIEINtAlMfCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, #"Material Used" = _t]),
    ChangeType = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Material Used", Int64.Type}}),
    Sum = List.Sum(Table.Distinct(ChangeType)[Material Used])
in
    Sum

 

Copy paste this code to the advanced editor in a new blank query to see how the solution works.

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors