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
robarivas
Post Patron
Post Patron

Slice by measure result (positive vs negative)

I have a DAX measure that tells me the variance between currently selected month and the month prior. For a certain dimension (let's say department) the variance can be either positive or negative. I want to add a slicer that lets me filter my visual (a treemap in this case) for either positive variances only or negative variances only. Knowing that a measure can't be a used as a slicer (nevermind the output of a measure) I am stumped as to how to acheive what I'm trying to do. I'd appreciate any help. Thank you.

6 REPLIES 6
v-qiuyu-msft
Community Support
Community Support

Hi @robarivas,

 

Is the issue solved? How about the result when you try my DAX in original post? If you have any question, please feel free to ask.

 

Best Regards,
Qiuyun Yu

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

For some reason I couldn't get the slicer visual to accept the Status field. However, I believe I resolved the issue using the information/techniques found in this link: http://www.daxpatterns.com/dynamic-segmentation/

Hi @robarivas,

 

Glad to hear you have resolved the issue.Smiley Happy  Would you please mark helpful replies as answers, so that we can close the thread?

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-qiuyu-msft
Community Support
Community Support

Hi @robarivas,

 

In your scenario, assume the measure you created to return variance named Difference, you can create a column to return "Positive" and "Negative" based on the measure values, then place this column in Slicer visual.

 

Status = if([Difference]>=0,"Positive","Negative")

 

q3.PNG

 

If the above method doesn't meet your requirement, please share some sample for our analysis.

 

Best Regards,
Qiuyun Yu

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

@robarivas

 

The first solution that came to my head is:

 

Create a table with 2 rows: Positive , Negative. Use this in slicer.

 

Next, create a measure:

 

 

Measure =
VAR ValtoTreeMap =
    VALUES ( Table1[Values] )
RETURN
    IF (
        HASONEVALUE ( Table2[Type] ),
        IF (
            VALUES ( Table2[Type] ) = "Positive",
            IF ( ValtoTreeMap >= 0, VALUES ( Table1[Values] ), BLANK () ),
            IF ( ValtoTreeMap < 0, ABS ( ValtoTreeMap ), BLANK () )
        )
    )


 

 




Lima - Peru
Greg_Deckler
Super User
Super User

I can think of a possible solution but it is dependent upon the scenario. Can you post some sample data and relationships?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.