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

Test the value of a slicer in DAX

I have a slicer with two items. I need to blank out several fields in the report if the second item in the slicer list is selected. How can I check which item in the list of the slicer is selected in DAX statement?

 

Thanks, Mark

2 ACCEPTED SOLUTIONS
AlexisOlson
Super User
Super User

If your slicer is on Table1[ColumnA], then VALUES(Table1[ColumnA]) should give you a list of distinct values that you have selected with your slicer. You can test if an item is in that list using IN. For example, if it's the text string "Second Item", then you'd write

 

"Second Item" IN VALUES(Table1[ColumnA])

which will return True or False.

View solution in original post

v-yuezhe-msft
Employee
Employee

@Anonymous,

Create a measure in your table using DAX below.

Measure= if(SelectedValue(Table[slicerfield])="seconditem name",<value_if_true>, <value_if_false>)  


If you still have questions, please share sampled data of your table and post expected result here.

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yuezhe-msft
Employee
Employee

@Anonymous,

Create a measure in your table using DAX below.

Measure= if(SelectedValue(Table[slicerfield])="seconditem name",<value_if_true>, <value_if_false>)  


If you still have questions, please share sampled data of your table and post expected result here.

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
AlexisOlson
Super User
Super User

If your slicer is on Table1[ColumnA], then VALUES(Table1[ColumnA]) should give you a list of distinct values that you have selected with your slicer. You can test if an item is in that list using IN. For example, if it's the text string "Second Item", then you'd write

 

"Second Item" IN VALUES(Table1[ColumnA])

which will return True or False.

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.