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

Create a Slicer or Filter For Values Across Numerous Columns

Hello,

 

I'm new to Power Bi. I'm modeling a dataset that has numerous columns for patient race (White, Black, Indian, etc) using values of "1" for Yes and "0" for No. Rows can contain a "1" value for more than one column (patient is both Black and White). I would like to create a slicer or filter where a user can select a race and the data will filter results for that race whenever there is a "1" value present whether it is the only race column containing a "1" value or has a "1" value in more than one race column.

 

Here is an example table:

 

Unique IDWhiteBlackIndianJapaneseFilipino
AA10000
BB01000
CC00100
DD00001
EE11000
FF00010

 

If the user were to filter for "Black" then I would expect both BB and EE be accounted for.

 

Any help with this would be greatly appreciated.

 

Thanks.

1 ACCEPTED SOLUTION
v-tangjie-msft
Community Support
Community Support

Hi @Jepas ,

 

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 slicer table and then we can create a measure. 

 

Slicer Table = DATATABLE ( 
    "Slicer", STRING, 
    {
        { "Black" },
        { "White" },
        { "Indian" },
        { "Japanese" },
        { "Filipino" }
    }
) 
Flag = SWITCH(TRUE(),
SELECTEDVALUE('Slicer Table'[Slicer])="Black" && MAX('Table'[Black])=1,1,
SELECTEDVALUE('Slicer Table'[Slicer])="White" && MAX('Table'[White])=1,1,
SELECTEDVALUE('Slicer Table'[Slicer])="Filipino" && MAX('Table'[Filipino])=1,1,
SELECTEDVALUE('Slicer Table'[Slicer])="Indian" && MAX('Table'[Indian])=1,1,
SELECTEDVALUE('Slicer Table'[Slicer])="Japanese" && MAX('Table'[Japanese])=1,1,
ISFILTERED('Slicer Table'[Slicer])=FALSE(),1,0)

 

(3) Place [flag=1] on visual object screening and then the result is as follows.

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

1 REPLY 1
v-tangjie-msft
Community Support
Community Support

Hi @Jepas ,

 

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 slicer table and then we can create a measure. 

 

Slicer Table = DATATABLE ( 
    "Slicer", STRING, 
    {
        { "Black" },
        { "White" },
        { "Indian" },
        { "Japanese" },
        { "Filipino" }
    }
) 
Flag = SWITCH(TRUE(),
SELECTEDVALUE('Slicer Table'[Slicer])="Black" && MAX('Table'[Black])=1,1,
SELECTEDVALUE('Slicer Table'[Slicer])="White" && MAX('Table'[White])=1,1,
SELECTEDVALUE('Slicer Table'[Slicer])="Filipino" && MAX('Table'[Filipino])=1,1,
SELECTEDVALUE('Slicer Table'[Slicer])="Indian" && MAX('Table'[Indian])=1,1,
SELECTEDVALUE('Slicer Table'[Slicer])="Japanese" && MAX('Table'[Japanese])=1,1,
ISFILTERED('Slicer Table'[Slicer])=FALSE(),1,0)

 

(3) Place [flag=1] on visual object screening and then the result is as follows.

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

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.