Skip to main content
cancel
Showing results for 
Search instead 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.

Reply
Misq
Helper I
Helper I

Use SWITCH only in Filtred values

Hi everyone,

I need to use SWITCH only for cases where there are FILTER values.

For example, the function SWITCH:
SWITCH(
TRUE(),
[Sales%] <0, "Less than 0%",
[Sales%] <= 0.1, "0%-10%",
[Sales%] >= 0.1, "10% or more"
)

The function should only be calculated if the following conditions apply for a given sales order:
[Sales$] >= 0,
[Sales#] >= 0

Is it at all possible to create a measure that will perform these calculations?

Translated with DeepL

2 REPLIES 2
ThomasWeppler
Skilled Sharer
Skilled Sharer

I am not sure switch is the right Dax function here. What exactly do you want to achieve with your code?

but in general when you want to use a filter on some dax code you do it like this.
calculate([code], [Sales$] >= 0, [Sales#] >= 0)

I hope this helps.

amitchandak
Super User
Super User

@Misq , Try like

 

if([Sales$] >= 0 && [Sales#] >= 0 ,

SWITCH(
TRUE(),
[Sales%] <0, "Less than 0%",
[Sales%] <= 0.1, "0%-10%",
[Sales%] >= 0.1, "10% or more"
), blank())

Helpful resources

Announcements
Microsoft Fabric Learn Together

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

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors