Forum Discussion
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.
- Anonymous6 years agoTry thisCheck =var first_val="FQC"Var Second_val="RHC"VAr SelectedList=ALLSELECTED('Parameter Location Type'[Location Type])returnSWITCH(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.
6 Replies
- amitchandak
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- AnonymousNot applicableChange bold part like this
Switch (true(),Allselected(tablename[slicercolumn]) in ("value1","value2"), conditions)
Thanks,
Pravin- msantillan
Helper II
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]))))
- AnonymousNot applicable
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.
Regards,
Xiaoxin Sheng