cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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
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
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

Super User III
Super User III

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
secondImage

Congratulations!

We are excited to announce the Power BI Super Users!

Wave Release 2

Check out the updates in Power BI.

Overview of Power BI 2020 release wave 2!

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

secondImage

The largest Power BI virtual conference

100+ sessions, 100+ speakers, Product managers, MVPs, and experts. All about Power BI. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors