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
my_microsoftacc
Frequent Visitor

Filter for multiple values in a cell

Let's say I have a table like this. I want to be able to find "Which store sells both Book and Chair" for example.

I'm thinking a slicer where I can search for 'book' and 'chair' and the table will adjust and give the answer.

 

Any idea how to achieve this? Thanks.

test store.PNG

2 ACCEPTED SOLUTIONS
v-tangjie-msft
Community Support
Community Support

Hi @my_microsoftacc ,

 

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

(2) We can create a table.

Products = 
FILTER(
    DISTINCT(
        SELECTCOLUMNS(
            GENERATE(
                Stores,
                VAR ProductsList = 
                    ADDCOLUMNS(
                        GENERATESERIES(1, MAXX(Stores, LEN([Products]) - LEN(SUBSTITUTE([Products], ",", "")) + 1)),
                        "Product", TRIM(MID(SUBSTITUTE([Products], ",", REPT(" ", 100)), ([Value] - 1) * 100 + 1, 100))
                    )
                RETURN ProductsList
            ),
            "Product", [Product]
        )
    ),[Product]<>BLANK())

(3)We can create a measure. 

Flag = IF(COUNTROWS(FILTER(VALUES(Products[Product]),CONTAINSSTRING(SELECTEDVALUE(Stores[Products]),[Product])))=COUNTROWS(VALUES(Products[Product])),1,0)

(4) Then the result is as follows.

vtangjiemsft_0-1689669678890.png

 

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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

Hi @my_microsoftacc ,

 

Update the measure.

Flag = IF(OR(COUNTROWS(FILTER(VALUES(Products[Product]),CONTAINSSTRING(SELECTEDVALUE(Stores[Products]),[Product])))=COUNTROWS(VALUES(Products[Product])),ISFILTERED('Products'[Product])=FALSE()),1,0)

vtangjiemsft_0-1690181012385.png

Best Regards,

Neeko Tang

View solution in original post

5 REPLIES 5
v-tangjie-msft
Community Support
Community Support

Hi @my_microsoftacc ,

 

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

(2) We can create a table.

Products = 
FILTER(
    DISTINCT(
        SELECTCOLUMNS(
            GENERATE(
                Stores,
                VAR ProductsList = 
                    ADDCOLUMNS(
                        GENERATESERIES(1, MAXX(Stores, LEN([Products]) - LEN(SUBSTITUTE([Products], ",", "")) + 1)),
                        "Product", TRIM(MID(SUBSTITUTE([Products], ",", REPT(" ", 100)), ([Value] - 1) * 100 + 1, 100))
                    )
                RETURN ProductsList
            ),
            "Product", [Product]
        )
    ),[Product]<>BLANK())

(3)We can create a measure. 

Flag = IF(COUNTROWS(FILTER(VALUES(Products[Product]),CONTAINSSTRING(SELECTEDVALUE(Stores[Products]),[Product])))=COUNTROWS(VALUES(Products[Product])),1,0)

(4) Then the result is as follows.

vtangjiemsft_0-1689669678890.png

 

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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

It worked! Thanks a lot. Just another question, right now if nothing is selected in the table, the original table is empty. So how can I adjust the measure so that if nothing is selected, the whole table shows?

Hi @my_microsoftacc ,

 

Update the measure.

Flag = IF(OR(COUNTROWS(FILTER(VALUES(Products[Product]),CONTAINSSTRING(SELECTEDVALUE(Stores[Products]),[Product])))=COUNTROWS(VALUES(Products[Product])),ISFILTERED('Products'[Product])=FALSE()),1,0)

vtangjiemsft_0-1690181012385.png

Best Regards,

Neeko Tang

amitchandak
Super User
Super User

@my_microsoftacc , One is a split column by delimiter in power bi or split it in dim

 

Power Query Split Column , Split Column By Delimiter: https://youtu.be/FyO9Vmhcfag

 

Power BI- Text Part slicer to filter/search text - https://youtu.be/MKKWeOqFG4c
https://medium.com/@amitchandak/power-bi-search-text-parts-in-text-ad2f9783ffa2

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Thanks for replying @amitchandak . I already know about this but it is not exactly what I'm looking for.

What you suggested works as an "or" search, so for example: store sells book or chair. The result is Store A, B and C.

But I want to have an "and" search. So in that case, store sells both book and chair, the result is only store A.

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.