Forum Discussion

my_microsoftacc's avatar
my_microsoftacc
Frequent Visitor
3 years ago
Solved

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 ...
  • Anonymous's avatar
    Anonymous
    3 years ago

    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.

     

     

    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. 

  • Anonymous's avatar
    Anonymous
    3 years ago

    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)

    Best Regards,

    Neeko Tang