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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Slicer Using Measure Based on Criteria

Hi,

 

Is it possible for a slicer to accommodate a measure based on criteria e.g. the screenshot showed criteria for Negative Variance, Negative Variance with No Sales, etc?

 

//NT

 

 

tksnota_0-1721167905988.png

 

8 REPLIES 8
Ashish_Mathur
Super User
Super User

Hi,

Which are the other crtieria you have?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
hnguy71
Super User
Super User

Hi @Anonymous ,

Assuming that the comments within your measure are derived by a logic, yes.

 

Let's assume you have a comment measure with something similar to this:

hnguy71_0-1721176107183.png

 

You'll need to create a disconnected slicer table that holds the same value. For example:

hnguy71_1-1721176174210.png

 

Next, you'll create a measure to determine which row you should keep:

hnguy71_2-1721176264889.png

 

Finally, add a filter on your table by filtering the measure for the value of 1.

hnguy71_3-1721176381477.png
To see it in action:

2024-07-16_19h34_12.gif

 

 

 



Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!
Anonymous
Not applicable

Do I need to create a separate table in the power query as the initial step?

Hi @Anonymous , 
A separate disconnected table, yes, but it doesn't need to be creaetd in power query if you don't feel like it. You can select "New Table" and use the DATATABLE function to create your table:

hnguy71_0-1721403266741.png

 






Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!
Anonymous
Not applicable

Hi,

 

My Comment is different from the one you'd shown. I created a new table and when I followed your dax all returned to zero as shown.

 

Comment_drd =
    SWITCH (
        TRUE (),
        'gbkmut_pns_drd'[Variance] = 0.001, "No Revenue",
        'gbkmut_pns_drd'[Variance] < 0 && gbkmut_pns_drd[abs] = 0, "Negative Variance with No Revenue",
        'gbkmut_pns_drd'[Variance] < 0, "Negative Variance",
        'gbkmut_pns_crd'[abs01] = BLANK() && gbkmut_pns_drd[abs] > 0, "No Cost But With Revenue"
        )
 
tksnota_0-1721639378306.png

 

tksnota_1-1721639429676.png

 

Hi @Anonymous 

Seems you're still missing the slicer on the page. Can you also share what's inside your "Filter Flag" meaesure?



Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!
Anonymous
Not applicable

Hi,

 

I created the filter as shown.

 

I'm also sharing you the dax i created for the filter flag

 

Filter Flag =
VAR CurrentClassification = gbkmut_pns_drd[Comment_drd]
VAR CurrentSelection = SELECTEDVALUE('Filter Comment'[Selection])
RETURN
SWITCH(
    TRUE(),
    CurrentSelection = "Negative Variance" && CurrentClassification = "Negative Variance",1,
    CurrentSelection = "Negative Variance with No Revenue" && CurrentClassification = "Negative Variance with No Revenue",1,
    CurrentSelection = "No Cost But With Revenue" && CurrentClassification = "No Cost But With Revenue",1,
    CurrentSelection = "No Revenue" && CurrentClassification = "No Revenue",1,
    CurrentSelection = "No Cost, No Revenue" && CurrentClassification = "No Cost,No Revenue",1,
    0
)

 

tksnota_0-1721720143027.png

 

Hi @Anonymous ,

One thing to keep in mind is that your string inside your comment measure must match the string inside your flag measure:

Filter Flag =
VAR CurrentClassification = [Comment_drd]
VAR CurrentSelection = SELECTEDVALUE('Filter Comment'[Selection])
RETURN
IF(CurrentSelection = CurrentClassification, 1, 0)

 
Also, make sure that there's a selection from your dropdown for it to turn from 0 to 1.

I've linked a sample for you so you can get a feel of what to do:
tksnota_filter_measure.pbix



Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.