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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
TimQ
Helper I
Helper I

Parsing comma separated values for slicer

I have a field text field called "Committee" that denotes a committee number for each record. A record can have more than one committee number associated with it, which is separated by commas, i.e., below:

Record ID |  Committee

1               |   1, 2, 4

2               |   1

3               |   3, 4, 12

 

I want to create a slicer that will return the records with a selected committee number, which ranges from 1 to 32. Using the example data above, a selected slicer value of "1" would return records 1 and 2, but not 3. What's the simplest way to do this? 

 

Thanks.

1 ACCEPTED SOLUTION
HotChilli
Super User
Super User

Unless there is a good reason for storing the data that way, I think you should use Power Query to split the Committee column into rows.

Use 'Split column'-> by delimiter (a comma) and choose 'Into rows' from the advanced section.

That will get you a more 'relational' table.  You can then use Committee in a slicer

View solution in original post

2 REPLIES 2
dax
Community Support
Community Support

Hi TimQ, 

Yes, you could refer to above suggestions to modift table structure like below(use below M query in edit queries)

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTLUMdIxUYrViVYyAvHALGMgy1jHRMfQSCk2FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [ID = _t, Committee = _t]),
    #"Split Column by Delimiter" = Table.SplitColumn(Source, "Committee", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Committee.1", "Committee.2", "Committee.3"}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Split Column by Delimiter", {"ID"}, "Attribute", "Value"),
    #"Removed Columns" = Table.RemoveColumns(#"Unpivoted Columns",{"Attribute"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Value", "slicer"}}),
    #"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns",{{"slicer", Int64.Type}})
in
    #"Changed Type"

Then you could use slicer field in Slicer, when you choose 1, it show  ID, 1 AND 2 in table

312.PNG313.PNG

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

HotChilli
Super User
Super User

Unless there is a good reason for storing the data that way, I think you should use Power Query to split the Committee column into rows.

Use 'Split column'-> by delimiter (a comma) and choose 'Into rows' from the advanced section.

That will get you a more 'relational' table.  You can then use Committee in a slicer

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.