cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
New Member

DAX: Sum of Distinct Value against category

Hi,

 

I am working on Power BI Project and have table with Category and Revenue Amount.

I am looking to SUM Distinct Revenue Amount of Same Category ,but not getting correct Syntax

 

I am looking to Create NEW DAX Measure, I cannot create Separate table in Model, Only Additional DAX Measure need can be added.

 

DistnctValue.PNG

When data is See for

Category  A : Output should be 10+20=30

Category B: Output Should be 5+15=20

Category C: Output Should be 3

Category D : Output Should be 1

Please assist with DAX Measure

1 ACCEPTED SOLUTION
Community Champion
Community Champion

Hi, @sheikhbiuser , you may use this measure

 

Sum Distinct = SUMX(SUMMARIZE(DATA, DATA[Category], DATA[Revenue]), DATA[Revenue])

 

Screenshot 2020-10-03 184732.png

btw, it's fairly easy to get the job done in Power Query.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTI0UIrVwWAaYYg6AZmmWFiGEKYzkGmMxnIBSSvFxgIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Category = _t, Revenue = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Revenue", Int64.Type}}),

    #"Grouped Rows" = Table.Group(#"Changed Type", {"Category"}, {{"Distinct", each List.Sum(List.Distinct([Revenue]))}})
in
    #"Grouped Rows"

Screenshot 2020-10-05 141432.png

View solution in original post

1 REPLY 1
Community Champion
Community Champion

Hi, @sheikhbiuser , you may use this measure

 

Sum Distinct = SUMX(SUMMARIZE(DATA, DATA[Category], DATA[Revenue]), DATA[Revenue])

 

Screenshot 2020-10-03 184732.png

btw, it's fairly easy to get the job done in Power Query.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTI0UIrVwWAaYYg6AZmmWFiGEKYzkGmMxnIBSSvFxgIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Category = _t, Revenue = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Revenue", Int64.Type}}),

    #"Grouped Rows" = Table.Group(#"Changed Type", {"Category"}, {{"Distinct", each List.Sum(List.Distinct([Revenue]))}})
in
    #"Grouped Rows"

Screenshot 2020-10-05 141432.png

View solution in original post

Helpful resources

Announcements
secondImage

Happy New Year from Power BI

This is a must watch for a message from Power BI!

December Update

Check it Out!

Click here to read more about the December 2020 Updates!

Community Blog

Check it Out!

Click here to read the latest blog and learn more about contributing to the Power BI blog!

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Top Solution Authors
Top Kudoed Authors