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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
ExcelMonke
Super User
Super User

Filtering using Switch / IF

I have a large data table with a column that returns two values based on an IF statement.

 

IF true THEN "Default"
ELSE "Not Default"

 

What I would like to do is to create a slicer that on a single click:

  1. Filters to all "Default" values
  2. Return all values are returned that are both "Default" AND "Not Default"

I've been playing around with Switch and IF functions and am not able to figure this one out. Any help is appreciated!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @ExcelMonke 

You can refer to the following solution

Sample data

vxinruzhumsft_0-1699858984337.png

 

1.You can create a slicer table 

vxinruzhumsft_1-1699859008371.png

 

2.Create a measure and put it to the visual filter

Measure =
IF (
    ISFILTERED ( 'Slicer'[Column1] ),
    IF (
        OR (
            SELECTEDVALUE ( 'Slicer'[Column1] ) = "default"
                && SELECTEDVALUE ( 'Table'[Column2] ) = "default",
            SELECTEDVALUE ( 'Slicer'[Column1] ) = "all"
        ),
        1,
        0
    ),
    1
)

 

vxinruzhumsft_2-1699859085431.png

 

Output

vxinruzhumsft_3-1699859098192.png

 

vxinruzhumsft_4-1699859104913.png

Best Regards!

Yolo Zhu

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

6 REPLIES 6
rsbin
Community Champion
Community Champion

@ExcelMonke ,

I think you're making this more complicated than need be.

Simply create a Slicer Visual and drag this column.  This will act as your Slicer

rsbin_0-1699556284700.png

Be sure to turn on the Select All option:

rsbin_1-1699556342328.png

Will this solve your issue?

Regards,

Thanks for the suggestion - I am actually hoping to do a single select option rather than a multi-select. 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





rsbin
Community Champion
Community Champion

@ExcelMonke ,

Then in Slicer Settings, turn On the Single select option:

rsbin_0-1699559904895.png

 

I don't think I was explaining what I was hoping for clearly. 
I want two single-click options:

  1. Filters to all "Default" values
  2. Return all values are returned that are both "Default" AND "Not Default"

i.e. one option to select default values, one option to effectively "select all"

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Anonymous
Not applicable

Hi @ExcelMonke 

You can refer to the following solution

Sample data

vxinruzhumsft_0-1699858984337.png

 

1.You can create a slicer table 

vxinruzhumsft_1-1699859008371.png

 

2.Create a measure and put it to the visual filter

Measure =
IF (
    ISFILTERED ( 'Slicer'[Column1] ),
    IF (
        OR (
            SELECTEDVALUE ( 'Slicer'[Column1] ) = "default"
                && SELECTEDVALUE ( 'Table'[Column2] ) = "default",
            SELECTEDVALUE ( 'Slicer'[Column1] ) = "all"
        ),
        1,
        0
    ),
    1
)

 

vxinruzhumsft_2-1699859085431.png

 

Output

vxinruzhumsft_3-1699859098192.png

 

vxinruzhumsft_4-1699859104913.png

Best Regards!

Yolo Zhu

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

 

rsbin
Community Champion
Community Champion

@ExcelMonke ,

Am really not understanding.  Based on your last explanation, that is why I suggested to Turn On the Select All option in your Slicer visual in my original reply. 

Your User, with one click, can Select all, or select one of the two options individually.  That is exactly what it is designed for.

The other option available to you is to use Bookmarks, Buttons and the Filter Pane.  But in my opinion, that seems to going to an extreme length to solve this issue.

Kind Regards,

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.