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
yybi123
Helper I
Helper I

How to use a measure as slicer?

Hi, I have a measure which categorise my data based on few statuses. How can I use this status measure as a slicer?

Status = IF(ISBLANK(Difference),"Gray", IF(Difference>0, "Green", IF(Difference<0, "Red", "Amber")))

- Difference is a measure as well-


I need a slicer with Gray, Green, Red , Amber so users can filter the data base on this. I have to use a measure for the status as a calulated column will not give me the desired results. I cant drag the measure as a slicer.
Thanks.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @yybi123 ,

 

Based on your description, you can so some steps as follows.

Here is my test table.

v-yuaj-msft_0-1616135482438.png

I create two measures as follows.

Difference = MAXX('Measure_Slicer_test',[D2]-[D1])
Status = IF(ISBLANK([Difference]),"Gray", IF([Difference]>0, "Green", IF([Difference]<0, "Red", "Amber")))
1. Create a calculated table.
Status = 

var x1=SUMMARIZE('Measure_Slicer_test',Measure_Slicer_test[Product],"Status",[Status])

return

SUMMARIZE(x1,[Status])

v-yuaj-msft_0-1616135592563.png

2. use "Status"[Status] to create a slicer.

v-yuaj-msft_1-1616135712903.png

3. create a measure, then drag it to the table visual of the original table and set the value as "1".

Measure_filter = 

var x1=SELECTEDVALUE('Status'[Status])

return

IF(ISBLANK(x1),1,IF([Status]=x1,1,0))

v-yuaj-msft_2-1616135828497.png

Result:

 031901.gif

Hope that's what you were looking for.

Best Regards,

Yuna

 

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

16 REPLIES 16
AnjanaTh
Frequent Visitor

I want to use a total score measure is a slicer , which consist of another measure whose values depends upon the selected value of other columns slicer .The above solution is not working as my measure is a dynamic one based on another measure which is based on slicer selection by user.Is there any workaroudn for this?

 

SaadNaser
Regular Visitor

great job mate, this is very usefull!!

forgetmenot
Helper I
Helper I

Can the same princple be applied to a Matrix? i'm struggling to filter on a Matrix as have added a measure and only want certain records to show.

Add the 'Measure_Filter' to the Matrix as a Field and see how it populates. This helped me visualize this workaround. You should see all 1's. From there you could try to identify why it is not working in the Matrix. Without seeing a model or screenshot, my first thought is it needs adjusting due to a hiearchy?

MallikVuyala58
New Member

Really helpful . Thanks

Anonymous
Not applicable

Hi,
I want to use measure in the slicer. And that measure consist of another two measures. So, I am not able to acheive this.

Anonymous
Not applicable

Hi @yybi123 ,

 

Based on your description, you can so some steps as follows.

Here is my test table.

v-yuaj-msft_0-1616135482438.png

I create two measures as follows.

Difference = MAXX('Measure_Slicer_test',[D2]-[D1])
Status = IF(ISBLANK([Difference]),"Gray", IF([Difference]>0, "Green", IF([Difference]<0, "Red", "Amber")))
1. Create a calculated table.
Status = 

var x1=SUMMARIZE('Measure_Slicer_test',Measure_Slicer_test[Product],"Status",[Status])

return

SUMMARIZE(x1,[Status])

v-yuaj-msft_0-1616135592563.png

2. use "Status"[Status] to create a slicer.

v-yuaj-msft_1-1616135712903.png

3. create a measure, then drag it to the table visual of the original table and set the value as "1".

Measure_filter = 

var x1=SELECTEDVALUE('Status'[Status])

return

IF(ISBLANK(x1),1,IF([Status]=x1,1,0))

v-yuaj-msft_2-1616135828497.png

Result:

 031901.gif

Hope that's what you were looking for.

Best Regards,

Yuna

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Hi!,
Can you help with a step further.

I want to have a multi select filter; and i think it does not work if one needs to select multiple items from the filter.
Could you help with telling a way to have filter based on measure for multiple selection also.

Thanks for you help.
Regards

To create a multi-select filter in Power BI based on a measure, you can use a workaround involving an additional table and a measure to connect the slicer to your data. 

try this: 

  1. Create a Table for Slicer Values: First, create a table that contains all possible values your measure can have. For example, if your measure results in categories like "Case1", "Case2", etc., create a table with these values.

  2. Create a Measure for Filtering: Next, create a measure that will be used to filter your data based on the slicer selection. This measure will compare the selected value from the slicer with the measure result.

  3. Use the Measure in a Slicer: Add the table you created to your report and use its column in a slicer. Then, use the measure you created as a filter on the relevant visuals.

Here's an example of how you can write the DAX for the measure:

MeasureFilter = 
VAR selectedValue = SELECTEDVALUE('New_Table'[Value])
VAR CurrentValue = [Latest order]
RETURN IF(CurrentValue == selectedValue, 1, 0)

In this example, New_Table is the table you created, and [Latest order] is your original measure. This measure will return 1 if the current value matches the selected value from the slicer, and 0 otherwise.

  1. Apply the Measure as a Filter: Finally, apply this measure as a filter to your visuals, setting it to show only when the measure equals 1. This way, you can filter your data based on multiple selections from the slicer.

Thanks for the work around. Simply Genius!

Hi @Anonymous ,

 

From calculated table [Status],
In case the orginial table have several month and business unit, how can we add a column to count how many product under each status, based on date and Business unit filter from Original table.

 

Drake0911_0-1704788912457.png

 

Great solution representing the inguinity of using the OOB PBI capablities. 


Thank you !

Hi Team,

 

If One date is fixed and another date is selected on slicer then substarct both dates. and create measure of Date Bucket.

How to create date bucket measure in slicer.

 

Thanks! I have a very similar problem. Did exactly the steps you described and it works for the respective page perfectly.

 

But in my PBI data model i have several pages with different visualizations. And, i do want to make this new slicer (green, red etc.) to be applied for all other pages as well, but it doesn't work at all. 

Any solutions for this?

Hope to hear from you.

 

Best,

The Challenger

Hi! 

I have the same issue. 

Did you find a solution? 

Thank you in advance 🙂

 

amitchandak
Super User
Super User

@yybi123 , You need to create an independent table with these measure values. and then use them in slicer with group(values)

refer example of binning and segmentation

https://www.daxpatterns.com/dynamic-segmentation/
https://radacad.com/grouping-and-binning-step-towards-better-data-visualization
my Video: https://youtu.be/CuczXPj0N-k

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

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.