cancel
Showing results 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.

Post Patron

## Custom Slicer: All values and all except one

Hello!

I'm having some trouble regarding the logic of my slicer.

I'm aware that to create a slicer, you have to drag the column and the unique values of that certain column will serve as choices for your slicer. But I have a different case.. I want to have a slicer (filter for my materials) where the options are:

• All materials
• All materials except material B

I have a list of materials (A to Z) and I created a calculated column:

``Material Filter = if(Query1[MATERIAL] <> "B", "All materials except material B", "All materials")``

But I think this is wrong haha! Because if I choose "All materials" only the values for material B will appear. Is there a way where I can have a DAX measure as a slicer filter? How can I create my own slicer with this logic?

1 ACCEPTED SOLUTION
Community Support

Hi @crln-blue ,

Based on your description, you can do some steps as follows.

1. create a table that contains only "All materials except material B" and "All materials". (I used "Enter Data" option)

2. create a measure and drag it to the filter of the table visual.(is equal to 1)

`Measure = var x1=SELECTEDVALUE('slicer'[S])var x2=IF(MAX('Query1'[material])<>BLANK(),"All materials")var x3=IF(MAX('Query1'[material])<>"B","All materials except material B")returnIF(x1="All materials",1,IF(x1=x3,1,0))`

Result:

Hope that's what you were looking for.

Best Regards,

Yuna

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

5 REPLIES 5
Community Support

Hi @crln-blue ,

I'm glad that I can help you resolve this issue. The max function in this measure is used to define the exact value of each row. The value of measure must be calculated according to the context. The logic you gave is that everything except B is "All materials except material B", and the rest is only B, so only B is called "All materials". My method is to create two different variables that will show different values when different conditions are met. So I think the MAX function is not the cause of the error.

Best Regards,

Yuna

Community Support

Hi @crln-blue ,

I'm glad that I can help you resolve this issue. The max function in this measure is used to define the exact value of each row because the value of measure should be calculated according to the context.

Best Regards,

Yuna

Community Support

Hi @crln-blue ,

Based on your description, you can do some steps as follows.

1. create a table that contains only "All materials except material B" and "All materials". (I used "Enter Data" option)

2. create a measure and drag it to the filter of the table visual.(is equal to 1)

`Measure = var x1=SELECTEDVALUE('slicer'[S])var x2=IF(MAX('Query1'[material])<>BLANK(),"All materials")var x3=IF(MAX('Query1'[material])<>"B","All materials except material B")returnIF(x1="All materials",1,IF(x1=x3,1,0))`

Result:

Hope that's what you were looking for.

Best Regards,

Yuna

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

Post Patron

Thanks @v-yuaj-msft ! This solved my problem. I did this but I did not use the MAX function for checking the material that's why my slicer is not reflecting in the matrix.

I just have a question, what's the MAX function in material for? I just want to understand the measure. Thanks again!

Super User

@crln-blue you can surely have a visual level filter for the slicer, read this post.

Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤

Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Announcements

#### 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

#### Power BI Monthly Update - April 2024

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

#### Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors