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
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
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.

June 2025 community update carousel

Fabric Community Update - June 2025

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