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

Creating a slicer based on measures

I know this has been covered but I haven't found a suitable resolution that works so I'm giving this a go fearing the worst:

 

I have four measures which calculate four different totals e.g. Americas Volume, UK Volume, Singapore Volume, Middle East Volume.  The measures use different datasets to get their totals.

I want to have a slicer or chiclet slicer which people can select which of these measures they want to see in the visualisation, so I could have all four measures in a graph, (which wouldn't look great initially), then when the slicer is selected the graph only displays the measure that's been selected. 

 

I tried sticking all the measures in a bar graph, but that isn't filtering my other chart, and also it doesn't look good.

 

Any ideas? 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

This can be done without too much trouble. 

 

1. Create a disconnected table with your the names you want to use as your Slicers. For example,create a table that has "Sales YTD" and "Sales LYTD"

 

2. Create a slicer using that table, being sure it's not related to any tables in the model

 

3. Create a measure that captures the value that is selected 

Selected Value=
SELECTEDVALUE( Table[Col] from #1, value if more than one values is selected)

https://docs.microsoft.com/en-us/dax/selectedvalue-function

 

4. Create another measure that will use the value in #3 in a SWITCH(TRUE() format)

  Show Selected:=
  SWITCH(
      TRUE(),
      [Selected Value]="Sales YTD",[SalesYTD],
      [Selected Value]="Sales LYTD",[SalesLYTD]
      what to show if more than 1 value used
  )

//selected value is the value of the measure in #3
//[Sales YTD] is just a place holder. This will be whatever measure you have

Put that in your matrix and should change based on the slicer selection from the inital table created.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

This can be done without too much trouble. 

 

1. Create a disconnected table with your the names you want to use as your Slicers. For example,create a table that has "Sales YTD" and "Sales LYTD"

 

2. Create a slicer using that table, being sure it's not related to any tables in the model

 

3. Create a measure that captures the value that is selected 

Selected Value=
SELECTEDVALUE( Table[Col] from #1, value if more than one values is selected)

https://docs.microsoft.com/en-us/dax/selectedvalue-function

 

4. Create another measure that will use the value in #3 in a SWITCH(TRUE() format)

  Show Selected:=
  SWITCH(
      TRUE(),
      [Selected Value]="Sales YTD",[SalesYTD],
      [Selected Value]="Sales LYTD",[SalesLYTD]
      what to show if more than 1 value used
  )

//selected value is the value of the measure in #3
//[Sales YTD] is just a place holder. This will be whatever measure you have

Put that in your matrix and should change based on the slicer selection from the inital table created.

Anonymous
Not applicable

That totally worked! Thank you @Anonymous  you're a genius! What a great solution. I love that it's blank until you select as well. Perfect. 

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.