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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
karthickpandiya
New Member

How to count list of occurrence of multiple values in a single column

My input value is like this

Product Quality
apple_high
apple_medium,apple_low,apple_high
apple_low,orange_high,mango_low
mango_high,orange_medium
orange_low,mango_low

 

I wanted my output to look like the below table

ProductHighMediumlow
apple212
orange111
mango102

 

Need some help on how to create a measure for this quer

1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSiwoyEmNz8hMz1CK1YFxc1NTMktzdSCcnPxyHayqQBL5RYl56RAZnVwgMx8kClYD4YEloIogpoIloSIgE5B0xQIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Product Quality" = _t]),
    Split = Table.TransformColumns(Source, {"Product Quality", each Table.FromRows(List.Transform(Text.Split(_,","), each Text.Split(Text.Trim(_), "_")), {"Brand", "Quality"})}),
    #"Expanded Product Quality" = Table.ExpandTableColumn(Split, "Product Quality", {"Brand", "Quality"}, {"Brand", "Quality"}),
    #"Duplicated Column" = Table.DuplicateColumn(#"Expanded Product Quality", "Brand", "Brand - Copy"),
    #"Pivoted Column" = Table.Pivot(#"Duplicated Column", List.Distinct(#"Duplicated Column"[Quality]), "Quality", "Brand - Copy", List.Count)
in
    #"Pivoted Column"

CNENFRNL_0-1663924690775.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

1 REPLY 1
CNENFRNL
Community Champion
Community Champion

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSiwoyEmNz8hMz1CK1YFxc1NTMktzdSCcnPxyHayqQBL5RYl56RAZnVwgMx8kClYD4YEloIogpoIloSIgE5B0xQIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Product Quality" = _t]),
    Split = Table.TransformColumns(Source, {"Product Quality", each Table.FromRows(List.Transform(Text.Split(_,","), each Text.Split(Text.Trim(_), "_")), {"Brand", "Quality"})}),
    #"Expanded Product Quality" = Table.ExpandTableColumn(Split, "Product Quality", {"Brand", "Quality"}, {"Brand", "Quality"}),
    #"Duplicated Column" = Table.DuplicateColumn(#"Expanded Product Quality", "Brand", "Brand - Copy"),
    #"Pivoted Column" = Table.Pivot(#"Duplicated Column", List.Distinct(#"Duplicated Column"[Quality]), "Quality", "Brand - Copy", List.Count)
in
    #"Pivoted Column"

CNENFRNL_0-1663924690775.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

Top Solution Authors