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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
TheoM
Helper I
Helper I

How to filter on one of multiple values in one column?

In my data model I have fact table, and in this table there is a column that can contain no, one or multiple values. If the column contains multiple values, the values are separated by ;

I want to filter the table on one or more single values.

Example: the column in my fact table looks like this:

 

A

null

A;B

B

A;B;C

C

A;C

 

When I filter on A, it should not only filter the rows that have A in the specified column, but also A;C, A;B and A;B;C

 

Best would be to create a relationship between the fact table and a table with all occuring single values, so in my report in can crossfilter, but I am not sure if that is possible.

 

I see similar problems on the forum, but none of them seems to fit perfectly. Can anyone help me with this?

1 ACCEPTED SOLUTION
v-yulgu-msft
Employee
Employee

Hi @TheoM,

 

Here are two solutions for your reference. But the first one only works when you select a single value in slicer each time.

 

Solution1.

Suppose you have a fact table and an extra table which lists all available slier items.

1.PNG2.PNG

 

Create measures:

selected item = SELECTEDVALUE(Test2[Column2])

check =
IF (
    NOT ( ISERROR ( FIND ( [selected item], SELECTEDVALUE ( Test1[Column1] ) ) ) ),
    1,
    0
)
 
Add measure [check] to "Visual Level filters" of table visual and set its value to 1.
3.PNG
 
Solution2
New a calculated table by crossjoin above two tables.
Test3 =
FILTER (
    ADDCOLUMNS (
        CROSSJOIN ( Test1, Test2 ),
        "Isexist", IF (
            Test2[Column2] <> BLANK (),
            ISERROR ( FIND ( Test2[Column2], Test1[Column1] ) ),
            IF ( Test1[Column1] = BLANK (), FALSE (), TRUE () )
        )
    ),
    [Isexist] = FALSE ()
)
4.PNG
 
Add Test3[Column2] to slicer, add Test3[Column1] to table visual.
5.PNG
 
Best regards,
Yuliana Gu
Community Support Team _ Yuliana Gu
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

4 REPLIES 4
v-yulgu-msft
Employee
Employee

Hi @TheoM,

 

Here are two solutions for your reference. But the first one only works when you select a single value in slicer each time.

 

Solution1.

Suppose you have a fact table and an extra table which lists all available slier items.

1.PNG2.PNG

 

Create measures:

selected item = SELECTEDVALUE(Test2[Column2])

check =
IF (
    NOT ( ISERROR ( FIND ( [selected item], SELECTEDVALUE ( Test1[Column1] ) ) ) ),
    1,
    0
)
 
Add measure [check] to "Visual Level filters" of table visual and set its value to 1.
3.PNG
 
Solution2
New a calculated table by crossjoin above two tables.
Test3 =
FILTER (
    ADDCOLUMNS (
        CROSSJOIN ( Test1, Test2 ),
        "Isexist", IF (
            Test2[Column2] <> BLANK (),
            ISERROR ( FIND ( Test2[Column2], Test1[Column1] ) ),
            IF ( Test1[Column1] = BLANK (), FALSE (), TRUE () )
        )
    ),
    [Isexist] = FALSE ()
)
4.PNG
 
Add Test3[Column2] to slicer, add Test3[Column1] to table visual.
5.PNG
 
Best regards,
Yuliana Gu
Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello Yuliana,

 

Solution 1 works. Solution 2 seems to work too, but I have to do a bit more work on my data model (define relationships and add a few more measures). I am sure I can make that work.

 

Thank you!

 

Best regards,

Theo

Anonymous
Not applicable

Hey @TheoM

 

What were the extra measures you needed to create to make this work?

 

I am having a hard time to do it. 

 

Thnaks, 

Sona

Greg_Deckler
Super User
Super User

Well, your best case scenario isn't going to work as far as I can tell. But, measures based around something like the IN operator would probably be the way to go.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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