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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
IF
Post Prodigy
Post Prodigy

switch

Hi,

I have the following data.

MonthUnitSoldTotal
12.2020A1012
12.2020B910
12.2020C57
12.2020D34
12.2020E1517
12.2020F2020
01.2021A1112
01.2021B810
01.2021C56
01.2021D23
01.2021E1418
01.2021F2022

I want to exclude the units "E" and "D" when I have the overall view. I do it with:

Measure = CALCULATE(DIVIDE(SUM(Main[Sold]), SUM(Main[Total])), FILTER(Main, Main[Unit]<>"E" && Main[Unit]<>"D"))
This works. However if i select E in slicer, it shows blank value in the card. However I want to see the value (0.828). Similar thing is valid for the D as well. I think I should use SWITCH, but don't know exactly how to use it. Could you help me?
33.jpg
Thanks in advance.
3 REPLIES 3
v-jayw-msft
Community Support
Community Support

Hi @IF ,

 

The table will be filtered by the slicer. If you select unit "D" or "E" in the slicer, there's no value to be calculated.

I don't understand the logic of the formula you are using because it just calclualtes the divided value of slicered [solid] and [total].

And I don't know how do you get 0.828. Can you please share the logic to us?

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
amitchandak
Super User
Super User

@IF , Try

Measure = CALCULATE(DIVIDE(SUM(Main[Sold]), SUM(Main[Total])), FILTER(Main, not(Main[Unit] in {"E" ,"D"})))

 

 

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

I tried but it doesn't work if I select unit "D" or "E" as well.

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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

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