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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors
Top Kudoed Authors