cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
msantillan Helper II
Helper II

DAX - Selecting 2 or more specific slicer values

Is there a way to show data based on two sepcific values selected on a slicer?

 

I have this DAX code:

 

Productive Utilization = SWITCH(true(),
SELECTEDVALUE('Resource Slicer Values'[Slicer Options])="Billable productive hours" &&
SELECTEDVALUE('Resource Slicer Values'[Slicer Options])="Non-Billable productive hours",
CALCULATE(SUM('Resource Table'[Application Productivity Percentage])),
SELECTEDVALUE('Resource Slicer Values'[Slicer Options])="Total",
(CALCULATE(SUM('Resource Table'[Application Productivity Percentage])+SUM('Resource Table'[Productivity Percentage]))))

 

The bold part of the code doesn't seem to be working as intended as seen on the image below. The case is if I both select Billable productive hours and Non Billable productive hours, it should show the value under. However, it returns blank.

 

q2snip.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
PR20048119 Memorable Member
Memorable Member

Re: DAX - Selecting 2 or more specific slicer values

 
Try this 
 
 
Check =
var first_val="FQC"
Var Second_val="RHC"
VAr SelectedList=ALLSELECTED('Parameter Location Type'[Location Type])
return
SWITCH(TRUE(),first_val in SelectedList || Second_val in SelectedList,1,0)
 
Note: chnage values and column name as per your requirement.
 
 
I tried above one and working absolutely fine .
 
Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar

If I resolve your problem Mark it as a solution and give kudos.

View solution in original post

6 REPLIES 6
Super User IV
Super User IV

Re: DAX - Selecting 2 or more specific slicer values

Try to count the values in a variable the use

 

Formula =
var _for = countx(filter('Resource Slicer Values','Resource Slicer Values'[Slicer Options] in {"Billable productive hours" ,"Non-Billable productive hours"}),
'Resource Slicer Values'[Slicer Options])

return
<Formula>

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges

Connect on Linkedin





Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
In case it does not help, please provide additional information and mark me with @
My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP,
HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Proud to be a Super User! Linkedin


PR20048119 Memorable Member
Memorable Member

Re: DAX - Selecting 2 or more specific slicer values

Change bold part like this

Switch (true(),Allselected(tablename[slicercolumn]) in ("value1","value2"), conditions)


Thanks,
Pravin
Community Support
Community Support

Re: DAX - Selecting 2 or more specific slicer values

HI @msantillan,

In fact, your conditions not works. When you select multiple items, selected values not equal to each value. (single value is included in selected values)

I'd like to suggest you use 'in' operator with allselected function to compare with multiple values that you selected in the slicer.

The IN operator in DAX 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin Sheng
If this post helps, please consider Accept it as the solution to help the other members find it more quickly
Learning resources: Power BI
Highlighted
msantillan Helper II
Helper II

Re: DAX - Selecting 2 or more specific slicer values

@PR20048119  I'm afraid there is an error when I'm using your logic. See code and image below:

Productive Utilization = SWITCH(true(),
ALLSELECTED('Resource Slicer Values'[Slicer Options]) in {"Billable productive hours", "Non-billable productive hours"},
CALCULATE(sum('Resource Table'[Application Productivity Percentage])),
SELECTEDVALUE('Resource Slicer Values'[Slicer Options])="Total",
(CALCULATE(SUM('Resource Table'[Application Productivity Percentage])+SUM('Resource Table'[Productivity Percentage]))))

snipq3.PNG
PR20048119 Memorable Member
Memorable Member

Re: DAX - Selecting 2 or more specific slicer values

 
Try this 
 
 
Check =
var first_val="FQC"
Var Second_val="RHC"
VAr SelectedList=ALLSELECTED('Parameter Location Type'[Location Type])
return
SWITCH(TRUE(),first_val in SelectedList || Second_val in SelectedList,1,0)
 
Note: chnage values and column name as per your requirement.
 
 
I tried above one and working absolutely fine .
 
Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar

If I resolve your problem Mark it as a solution and give kudos.

View solution in original post

msantillan Helper II
Helper II

Re: DAX - Selecting 2 or more specific slicer values

Thanks!

Helpful resources

Announcements
New Ranks Launched March 24th!

New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

‘Better Together’ Contest Finalists Announced!

‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Arun 'Triple A' Event Video, Q&A, and Slides

Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Join THE global Microsoft Power Platform event series.

Join THE global Power Platform event series.

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors