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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

How to filter a column with strings of product categories

Dear Community

I have a dataset with a column that is a string of many products:

ShipmentProducts (string)
1Apple, Banana, Pear, Melon, Grapes
2Kiwi
3Banana, Pear
4Orange, Berry, Mango, Grapes


I need to be able to filter the data set based on the products, so I need to be able to have a filter where the user can choose 'Grapes', and then only shipment 1 and 4 is shown. There are as many products types as there is types of fruit (so a lot), how can I filter such data set with such a column that have merged products in one column?

Thank you very much in advance. Always appreciate the help in here 🙂

Sincerely, Signe

2 ACCEPTED SOLUTIONS
shafiz_p
Super User
Super User

Hi @Anonymous You can split Products (String) column by comma (,) delimiter in power query. Then select column Shipment, and unpivot other columns. This way you can filter product as you want. For example, select graphs and it will show only shipment 1, and 4. Use below example codes to solve the problem :

let

 

Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],


TypeChange = Table.TransformColumnTypes(Source,{{"Shipment", Int64.Type}, {"Products (string)", type text}}),


SplitColumnbyDelimiter = Table.SplitColumn(
TypeChange,
"Products (string)",
Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv),
{"Products (string).1", "Products (string).2", "Products (string).3", "Products (string).4", "Products (string).5"}
),


UnpivotOtherColumn = Table.UnpivotOtherColumns(SplitColumnbyDelimiter, {"Shipment"}, "Attribute", "Value"),
RemovedColumns = Table.RemoveColumns(UnpivotOtherColumn,{"Attribute"}),
RenamedColumns = Table.RenameColumns(RemovedColumns,{{"Value", "Products"}}),
TrimmedText = Table.TransformColumns(RenamedColumns,{{"Products", Text.Trim, type text}})


in
TrimmedText

 

Hope this helps!!

If this solved your problem, please mark it as a solution!!

View solution in original post

Anonymous
Not applicable

Hi, @shafiz_p 

thanks for your concern about this issue.  

I am in favor of your idea.  

 

Hi, @Anonymous 

I am glad to help you.   

 

According to your description, you want to know how to filter a column with strings of product categories? 

  

If I understand you correctly, then you can refer to my solution.  

 

First, you can use New table in Power BI Desktop to create a table with all the products: Separate the products in the table with ',' and then distinct the separated products. 

vfenlingmsft_0-1722839161052.png

ProductsTable = 
DISTINCT (
    SELECTCOLUMNS (
        ADDCOLUMNS (
            GENERATESERIES (
                1,
                PATHLENGTH (
                    SUBSTITUTE ( CONCATENATEX ( Table1, Table1[Product(string)], "," ), ",", "|" )
                )
            ),
            "Product",
                TRIM (
                    PATHITEM (
                        SUBSTITUTE ( CONCATENATEX ( Table1, Table1[Product(string)], "," ), ",", "|" ),
                        [Value]
                    )
                )
        ),
        "Product", [Product]
    )
)

 

Then create a Measure to determine if the value selected by Slicer exists in Product(string): 

vfenlingmsft_1-1722839161054.png

 

MEASURE = 
VAR searchvalue =
    SELECTEDVALUE ( ProductsTable[Product] )
RETURN
    IF (
        CONTAINSSTRING (
            CONCATENATEX ( Table1, Table1[Product(string)], "," ),
            searchvalue
        ),
        1,
        0
    )

 

Finally apply Measure to visual: 

vfenlingmsft_2-1722839173211.png

 

 

I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Fen Ling,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi, @shafiz_p 

thanks for your concern about this issue.  

I am in favor of your idea.  

 

Hi, @Anonymous 

I am glad to help you.   

 

According to your description, you want to know how to filter a column with strings of product categories? 

  

If I understand you correctly, then you can refer to my solution.  

 

First, you can use New table in Power BI Desktop to create a table with all the products: Separate the products in the table with ',' and then distinct the separated products. 

vfenlingmsft_0-1722839161052.png

ProductsTable = 
DISTINCT (
    SELECTCOLUMNS (
        ADDCOLUMNS (
            GENERATESERIES (
                1,
                PATHLENGTH (
                    SUBSTITUTE ( CONCATENATEX ( Table1, Table1[Product(string)], "," ), ",", "|" )
                )
            ),
            "Product",
                TRIM (
                    PATHITEM (
                        SUBSTITUTE ( CONCATENATEX ( Table1, Table1[Product(string)], "," ), ",", "|" ),
                        [Value]
                    )
                )
        ),
        "Product", [Product]
    )
)

 

Then create a Measure to determine if the value selected by Slicer exists in Product(string): 

vfenlingmsft_1-1722839161054.png

 

MEASURE = 
VAR searchvalue =
    SELECTEDVALUE ( ProductsTable[Product] )
RETURN
    IF (
        CONTAINSSTRING (
            CONCATENATEX ( Table1, Table1[Product(string)], "," ),
            searchvalue
        ),
        1,
        0
    )

 

Finally apply Measure to visual: 

vfenlingmsft_2-1722839173211.png

 

 

I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Fen Ling,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

shafiz_p
Super User
Super User

Hi @Anonymous You can split Products (String) column by comma (,) delimiter in power query. Then select column Shipment, and unpivot other columns. This way you can filter product as you want. For example, select graphs and it will show only shipment 1, and 4. Use below example codes to solve the problem :

let

 

Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],


TypeChange = Table.TransformColumnTypes(Source,{{"Shipment", Int64.Type}, {"Products (string)", type text}}),


SplitColumnbyDelimiter = Table.SplitColumn(
TypeChange,
"Products (string)",
Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv),
{"Products (string).1", "Products (string).2", "Products (string).3", "Products (string).4", "Products (string).5"}
),


UnpivotOtherColumn = Table.UnpivotOtherColumns(SplitColumnbyDelimiter, {"Shipment"}, "Attribute", "Value"),
RemovedColumns = Table.RemoveColumns(UnpivotOtherColumn,{"Attribute"}),
RenamedColumns = Table.RenameColumns(RemovedColumns,{{"Value", "Products"}}),
TrimmedText = Table.TransformColumns(RenamedColumns,{{"Products", Text.Trim, type text}})


in
TrimmedText

 

Hope this helps!!

If this solved your problem, please mark it as a solution!!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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