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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

Add DAX preceding month date filter to a measure

Hi all,

 

I've had a hunt for a solution, though starting from a pretty limied level of knowledge which doesn't help...

 

I have the following measure applied to my data, which gives me the accompanying Table. I got these values even though I've only specified "FAI", so suspect that's not helping things. The '0' is added to ensure the table adds a 0 when there's a null value

 

To Date = CALCULATE(COUNTAX('IR H&S Incident Register','IR H&S Incident Register'[Classification]="FAI"))+0
 
table.PNG
What I'd like to do now is apply a date filter to this, to calculate incidents which have occured in the preceding month. I know I could do it with a visual level filter, but not in the same visual.
 
Hope you can help!
1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

To use this measure should work.

To Date =
VAR this_month =
    FORMAT ( TODAY (), "mm-yyyy" )
RETURN
    CALCULATE (
        COUNTAX (
            'IR H&S Incident Register',
            'IR H&S Incident Register'[Classification] = "FAI"
        ),
        FILTER (
            'IR H&S Incident Register',
            FORMAT ( 'IR H&S Incident Register'[date], "mm-yyyy" ) = thsi_month
        )
    ) + 0
Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

1 REPLY 1
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

To use this measure should work.

To Date =
VAR this_month =
    FORMAT ( TODAY (), "mm-yyyy" )
RETURN
    CALCULATE (
        COUNTAX (
            'IR H&S Incident Register',
            'IR H&S Incident Register'[Classification] = "FAI"
        ),
        FILTER (
            'IR H&S Incident Register',
            FORMAT ( 'IR H&S Incident Register'[date], "mm-yyyy" ) = thsi_month
        )
    ) + 0
Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.

Top Solution Authors
Top Kudoed Authors