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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

Dax calc help

Hello All,

 

I want help in formulating DAX for my use case.

Sample data is below. I want to show/FILTER only those rows whose latest month (MAR) value is >0.

Creating a if statement on the value field >0 is applying on all the months, BUT, I want it to apply only on latest MAR month.

 

As such Name "F" should filter out per my result. How can i get this. Please help.

 

NameMAR FEBJAN
A181416
B212213
C11716
D1922-12
E10-7-11
F-111016
G147

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous,

According to your description, your table seems to contain multiple month fields with values and you are try to filter on them to hide the last month records that than less than zero?

If this is a case, I'd like to suggest you do unpivot columns on your month fields to convert them to attitude and value fields.

Unpivot columns (Power Query) 

Then you can write a measure formula and use on 'visual level filter' to filter last month records.

Applying a measure filter in Power BI 

measure =
VAR list =
    ADDCOLUMNS (
        VALUES ( Table[Attribute] ),
        "Date", DATEVALUE ( [Attribute] & "/1" )
    )
VAR _lastMonth =
    MAXX ( list, [Date] )
VAR currValue =
    CALCULATE (
        SUM ( Table[Value] ),
        FILTER ( ALLSELECTED ( Table ), [Attribute] = FORMAT ( _lastMonth, "MMM" ) ),
        VALUES ( Table[Name] )
    )
RETURN
    IF (
        SELECTEDVALUE ( Table[Attribute] ) = FORMAT ( _lastMonth, "MMM" )
            && currValue > 0,
        "Y",
        "N"
    )

Regards,

Xiaoxin Sheng

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @Anonymous,

According to your description, your table seems to contain multiple month fields with values and you are try to filter on them to hide the last month records that than less than zero?

If this is a case, I'd like to suggest you do unpivot columns on your month fields to convert them to attitude and value fields.

Unpivot columns (Power Query) 

Then you can write a measure formula and use on 'visual level filter' to filter last month records.

Applying a measure filter in Power BI 

measure =
VAR list =
    ADDCOLUMNS (
        VALUES ( Table[Attribute] ),
        "Date", DATEVALUE ( [Attribute] & "/1" )
    )
VAR _lastMonth =
    MAXX ( list, [Date] )
VAR currValue =
    CALCULATE (
        SUM ( Table[Value] ),
        FILTER ( ALLSELECTED ( Table ), [Attribute] = FORMAT ( _lastMonth, "MMM" ) ),
        VALUES ( Table[Name] )
    )
RETURN
    IF (
        SELECTEDVALUE ( Table[Attribute] ) = FORMAT ( _lastMonth, "MMM" )
            && currValue > 0,
        "Y",
        "N"
    )

Regards,

Xiaoxin Sheng

Pragati11
Super User
Super User

Hi @Anonymous ,

 

Consider following sample data:

Pragati11_0-1597928630231.png

Create a caluclated column as follows:

newCol = CALCULATE(SUM(DaxCalc[Mar]), DaxCalc[Mar] > 0)
 
Move this to your table visual, you get following output:
q1.png 
 
Thanks,
Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

amitchandak
Super User
Super User

@Anonymous , this data should be unpivoted

https://radacad.com/pivot-and-unpivot-with-power-bi
Transpose : https://yodalearning.com/tutorials/power-query-helps-transposing-data/

 

an with year.

 

In this case, you can do is put a visual level filter of [MAR] >0

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Greg_Deckler
Community Champion
Community Champion

@Anonymous - Is that really how your data looks? Thinking you should unpivot those month columns.



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
harshnathani
Community Champion
Community Champion

HI @Anonymous ,

 

Create a visual filter

 

1.jpg

 

Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors