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
Ahead4097
Helper I
Helper I

Switch Function Help?

I'm not sure if Switch is the right function I would need to use or not, but basically I'm looking to make it to where "Health 4 All" could change with a filter or a table selection. I'd like to be able to select a different option, and have it change inside my formulas. 

 

Is Switch the function I would want to use, or would this need to be a VAR function? 


Need help!

 

daxdax

1 ACCEPTED SOLUTION
v-eachen-msft
Community Support
Community Support

Hi @Ahead4097 ,

 

I noticed that you have used some IF() functions, so you could replace it with SWITCH() function.

For example:

SWITCH(
       TRUE(),
       [Measure] = "YOUR CONDITION1",
       RESULT1 YOU NEED,
       [Measure] = "YOUR CONDITION2",
       RESULT2 YOU NEED
)

 

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

View solution in original post

3 REPLIES 3
v-eachen-msft
Community Support
Community Support

Hi @Ahead4097 ,

 

I noticed that you have used some IF() functions, so you could replace it with SWITCH() function.

For example:

SWITCH(
       TRUE(),
       [Measure] = "YOUR CONDITION1",
       RESULT1 YOU NEED,
       [Measure] = "YOUR CONDITION2",
       RESULT2 YOU NEED
)

 

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

Can you provide a sample of data and show what your filters would look like and the expected result?



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

I've attached some photos of the slicer, the data sample, and the end result. 

I have multiple measures that are using the Subject "Health 4 All" as a filter. I'm trying to get it to where I'll be able to slice the Subject, and "Health 4 All" will change in each of my measures to the selected Subject. 

 

Sorry for all the black...had to scrub. 

 

Measure examples:

Health4All Display Location =
IF([Health4All Type Built]="No Display","",
IF([Health4All Status] = "Display Unable to be Built", "",
CALCULATE(
LASTNONBLANK('View Responses'[Response Text],0),
FILTER('View Responses','View Responses'[Question] = "Where was the display built?"),
FILTER('View Responses', 'View Responses'[Subject] = "Health 4 All"),
FILTER('View Responses','View Responses'[Visit Date] = [Latest Visit Date User]))))
 
Health4All Status =
CALCULATE(
LASTNONBLANK('View Responses'[Option Text],0),
FILTER('View Responses', 'View Responses'[Subject] = "Health 4 All"),
FILTER('View Responses','View Responses'[Question] = "What is the status of promotional compliance?"),
FILTER('View Responses','View Responses'[Visit Date] = [Latest Visit Date User]))
 
Health4All Type Built =
IF([Health4All Status] = "Display Unable to be Built", "",
CALCULATE(
LASTNONBLANK('View Responses'[Response Text],0),
FILTER('View Responses','View Responses'[Question] = "What type of display was built?"),
FILTER('View Responses', 'View Responses'[Subject] = "Health 4 All"),
FILTER('View Responses','View Responses'[Visit Date] = [Latest Visit Date User])))
 
Health4All Unable Response =
IF([Health4All Status]= "I Built a Select Number of SKU's", "",
IF([Health4All Status] = "I Built Display on Previous Visit", "",
IF([Health4All Status] = "Display Built By Store", "",
CALCULATE(
LASTNONBLANK('View Responses'[Response Text],0),
FILTER('View Responses','View Responses'[Question] = "Why was the display unable to be successfully built?"),
FILTER('View Responses', 'View Responses'[Subject] = "Health 4 All"),
FILTER('View Responses','View Responses'[Visit Date] = [Latest Visit Date User])))))
 
End Result TableEnd Result TableData SampleData SampleSlicerSlicer

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.