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
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
Anonymous
Not applicable

 
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
v-shex-msft
Community Support
Community Support

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
If this post helps, please consider accept as solution to help other members find it more quickly.
amitchandak
Super User
Super User

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

Anonymous
Not applicable

Change bold part like this

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


Thanks,
Pravin

@Anonymous  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
Anonymous
Not applicable

 
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.

Thanks!

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