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.
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 ID | White | Black | Indian | Japanese | Filipino |
AA | 1 | 0 | 0 | 0 | 0 |
BB | 0 | 1 | 0 | 0 | 0 |
CC | 0 | 0 | 1 | 0 | 0 |
DD | 0 | 0 | 0 | 0 | 1 |
EE | 1 | 1 | 0 | 0 | 0 |
FF | 0 | 0 | 0 | 1 | 0 |
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.
Solved! Go to Solution.
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.
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.
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.
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.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
106 | |
105 | |
79 | |
69 | |
61 |
User | Count |
---|---|
143 | |
104 | |
103 | |
82 | |
70 |