Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.