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
AmberJane
Helper II
Helper II

Separate products that are listed in data with , or ;

For some reason I am not able to add my test data. I am receiving the error the file type (.pbix) is not supported so if anyone has any ideas as to why I am receiving that please let me know. I have attached a screenshot of the data and report below for my question. 

 

Data: 

AmberJane_0-1645636983448.png

 

Report: 

 

AmberJane_0-1645637475520.png

 

Would like to see the values separated by ; counted within its appropriate product.

 

So I would expect to see:

 

Apples 3

Oranges 3

Pineapples 1

Strawberries 2

 

1 ACCEPTED SOLUTION
AmberJane
Helper II
Helper II
2 REPLIES 2
AmberJane
Helper II
Helper II

lbendlin
Super User
Super User

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WciwoyEktVtJRMlKK1YFxrf2LEvPSwcKGYGF0fkBmXmoiilLr4JKixPKk1KKiTCR1mIKxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Product = _t, ct = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Product", type text}, {"ct", Int64.Type}}),
    #"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Changed Type", {{"Product", Splitter.SplitTextByDelimiter(";", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Product"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Product", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type1", {"Product"}, {{"Count", each List.Sum([ct]), type nullable number}})
in
    #"Grouped Rows"
How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".

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.