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 September 15. Request your voucher.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors