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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
marcelmuench
Regular Visitor

Slicer with if conditions

Hi community,

 

first of all: Happy new year!

 

 

We have a sales dashboard, with some slicers in it. For one of the slicers we've created a custom column which is based on if conditions.

 

Customer Cluster =
switch(true(),
if('Sales'[Channel] = "1",TRUE(),FALSE()),"Direct",
if('Sales'[Customer]="5",TRUE(),FALSE()),"Customer XY",
if('Sales'[Category]= "6",TRUE(),FALSE()),"TVs",
"All Others")

This one is working good, if I choose "Direct" in the slicers. If I choose "Customer XY", then all of the sales data with Channel = 1 are missing. Same if I choose "TVs". I know, this is due to the if logic. But this leads to my question. Is there any possibility to have the whole figures for each value I choose in the slicer, and not just the "rest of it".

 

I hope you're able to help me out with this.

 

Thanks a lot.

 

Best regards

1 ACCEPTED SOLUTION
AlB
Community Champion
Community Champion

@marcelmuench 

Here is a possible solution. You might have to adapt it, since you still haven't explained the requirements in detail.

See it all at work in the attached file.

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

 

View solution in original post

7 REPLIES 7
AlB
Community Champion
Community Champion

@marcelmuench 

Here is a possible solution. You might have to adapt it, since you still haven't explained the requirements in detail.

See it all at work in the attached file.

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

 

AlB
Community Champion
Community Champion

@marcelmuench 

Ok. Like i said,  you need to specify exactly how you need this to work for all cases. Otherwise we'll be running in circles.  From what I see having a column for the slicer is not the best option here since that implies each row in your table can belong only to one cluster.

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

What are the other possibilities besides a column? I think it's not possible to have a measure as a slicer. What would you recommend to do in this case?

AlB
Community Champion
Community Champion

@marcelmuench 

Of course. You need to specify clearly how the clusters are assigned. What happens exactly when more than one of the conditions is met, like in both the rows you are showing? This should fix the issue at hand, but might break in other cases without futher clarification:

Customer Cluster =
SWITCH (
    TRUE (),
    'Sales'[Customer] = "5", "Customer XY",
    'Sales'[Channel] = "1", "Direct",
    'Sales'[Category] = "6", "TVs",
    "All Others"
)

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

 

Thanks! But at the end TV is 0, instead of 300. How is it possible to specify the clusters? Don't know how to do that ☹️

marcelmuench
Regular Visitor

Thanks for your reply!

 

For example:

 

ChannelCustomerCategoryValue
156100
256200

 

Now I set the slicer to "Direct" and the result is 100 - which is correct.

If I select "Customer XY", then I get 200, but i expect 300 as a result.

 

I hope you understood what I want to do now.

AlB
Community Champion
Community Champion

Hi @marcelmuench 

Please explain this better:

Is there any possibility to have the whole figures for each value I choose in the slicer, and not just the "rest of it".

I don't understand what you want to do. Show an example based on sample data, oncludign the expected result

In any case, you do not need the IFs. To start with, you can simplify your currrent code:

Customer Cluster =
SWITCH (
    TRUE (),
    'Sales'[Channel] = "1", "Direct",
    'Sales'[Customer] = "5", "Customer XY",
    'Sales'[Category] = "6", "TVs",
    "All Others"
)

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

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!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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