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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

Splitting Cell Values and then distinct counting them

Hi there,

 

I am trying to split a column with multiple cell values and then hoping to create a visual to count how many times these values appear. I've found the answer to splitting the cells but am having trouble trying to create the visual. I am currently stuck at step 2 as I'm not too sure how we can combine the different columns that were broken down and put them into a visual. Any help would be great 🙂 

 

Step 1: Splitting values

Weilsong_0-1643966241839.png

Step 2: Distinct Count how many times each value appear (What I want to achieve on my Canvas)

Weilsong_1-1643966289125.png

 

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

I'd recommend changing step one to split into rows instead of columns.

AlexisOlson_0-1643991010292.png

 

If you do this, then you can finish with two clicks: Group By > OK.

 

Here's a full sample query you can paste into the Advanced Editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WciwoyEnVUQhITSzSUXBKzANCpVidaCXvzPJMHQXf1Jz8PIgsWNQptaioEsICK9VRgOr3L0rMS08FywRk5qUmIovCFUHMhBgWCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Category = _t]),
    #"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(Source, {{"Category", Splitter.SplitTextByDelimiter(", ", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Category"),
    #"Grouped Rows" = Table.Group(#"Split Column by Delimiter", {"Category"}, {{"Count", each Table.RowCount(_), Int64.Type}})
in
    #"Grouped Rows"

View solution in original post

4 REPLIES 4
AlexisOlson
Super User
Super User

I'd recommend changing step one to split into rows instead of columns.

AlexisOlson_0-1643991010292.png

 

If you do this, then you can finish with two clicks: Group By > OK.

 

Here's a full sample query you can paste into the Advanced Editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WciwoyEnVUQhITSzSUXBKzANCpVidaCXvzPJMHQXf1Jz8PIgsWNQptaioEsICK9VRgOr3L0rMS08FywRk5qUmIovCFUHMhBgWCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Category = _t]),
    #"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(Source, {{"Category", Splitter.SplitTextByDelimiter(", ", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Category"),
    #"Grouped Rows" = Table.Group(#"Split Column by Delimiter", {"Category"}, {{"Count", each Table.RowCount(_), Int64.Type}})
in
    #"Grouped Rows"
Anonymous
Not applicable

Thank you so much! This made everything so much simplier~

mahoneypat
Microsoft Employee
Microsoft Employee

You should unpivot the columns those columns to make your analysis easier. Select the first column in the query editor, right click and choose "Unpivot Other Columns". Delete the first column. Then you should have two columns - "Attribute" (Fruit1, Fruit2, Fruit3, ...) and "Value" (Apple, Pear, Melon, Orange, ...).  You can then put the Value column in a table (Don't Aggregate) and a simple measure of COUNTROWS(YourTableName).

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

Hi there, thanks for this solution! 🙂 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors