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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
crln-blue
Post Patron
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?

 

Thanks a lot in advance!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

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)

v-yuaj-msft_0-1612245948315.png

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")

return

IF(x1="All materials",1,IF(x1=x3,1,0))

v-yuaj-msft_1-1612246100895.png

Result:

v-yuaj-msft_2-1612246139573.pngv-yuaj-msft_3-1612246152552.png

 

 

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.

 

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

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

Anonymous
Not applicable

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

Anonymous
Not applicable

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)

v-yuaj-msft_0-1612245948315.png

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")

return

IF(x1="All materials",1,IF(x1=x3,1,0))

v-yuaj-msft_1-1612246100895.png

Result:

v-yuaj-msft_2-1612246139573.pngv-yuaj-msft_3-1612246152552.png

 

 

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.

 

Thanks @Anonymous ! 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!

parry2k
Super User
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.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.