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

Choose between measures in a slicer

Hi,

 

In a table, I have sales in Value, Volume and Units in different columns. In the table and/or chart, I would like to be able to choose if I want to see Value, Volume or Units in a filter of a slicer

 

Is that possible?

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @Anonymous,

 

You can refer to below steps to achieve your requirement:

 

1. Create a Selector table as source of slicer.

Selector = UNION(ROW("Type","Amount"),ROW("Type","Value"),ROW("Type","Unit"))

9.PNG

 

 

2. Write measure to original table to choose display item based on slicer.

Dynamic Display = 
var selectitem=IF(HASONEVALUE(Selector[Type]),VALUES(Selector[Type]),BLANK())
return
SWITCH(selectitem,"Amount",MAX('Table'[Amount]),"Unit",MAX('Table'[Unit]),"Value",MAX('Table'[Value]),BLANK()) 

 

3. Create table visual and slicer.

10.PNG

 

Result:

11.PNG

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

10 REPLIES 10
v-shex-msft
Community Support
Community Support

Hi @Anonymous,

 

You can refer to below steps to achieve your requirement:

 

1. Create a Selector table as source of slicer.

Selector = UNION(ROW("Type","Amount"),ROW("Type","Value"),ROW("Type","Unit"))

9.PNG

 

 

2. Write measure to original table to choose display item based on slicer.

Dynamic Display = 
var selectitem=IF(HASONEVALUE(Selector[Type]),VALUES(Selector[Type]),BLANK())
return
SWITCH(selectitem,"Amount",MAX('Table'[Amount]),"Unit",MAX('Table'[Unit]),"Value",MAX('Table'[Value]),BLANK()) 

 

3. Create table visual and slicer.

10.PNG

 

Result:

11.PNG

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Great and useful answer, thanks. 

how would you then make the column header displays the name of the slicer selection?

How do you create the "Type" table that the selector table is referencing?

Anonymous
Not applicable

Go to "Modeling"

image.png

 

Select "New Table"

image.png

 

Copy / paste the text into the DAX code line

image.png

 

Change the code as needed and press enter... You can add more lines in the table later

 

 

 

Thank you - I have figured out another method.

Anonymous
Not applicable

 
Anonymous
Not applicable

FANTASTIC!!! Works very well. Thank you very much!

fhill
Resident Rockstar
Resident Rockstar

I watched this training recently, and I belive they are doing something simular to what you are asking.  They use a slicer to choose between 3 values on a line chart.

 

http://pragmaticworks.com/Training/Details/Advanced-DAX-Problem-Design-Solution

 

Forrest




Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




Anonymous
Not applicable

Hi Fhill,

 

This also a good alternative - and will use this as well as it works well with measures. One issue though is that in tables the measures will still be in the table columns when it is deselected - just with no values, If one have a lot of measueres that dose not work very well.

 

- But it charts it's perfect!

 

Kent

Anonymous
Not applicable

Hi,

 

In a table, I have sales in Value, Volume and Units in different columns. In the table and/or chart, I would like to be able to choose if I want to see Value, Volume or Units in a filter of a slicer

 

Is that possible?

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.