cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
TD-BI-BNE Frequent Visitor
Frequent Visitor

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

Accepted Solutions
Community Support Team
Community Support Team

Re: Add DAX preceding month date filter to a measure

Hi @TD-BI-BNE ,

 

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 other members find it more quickly.

View solution in original post

1 REPLY 1
Community Support Team
Community Support Team

Re: Add DAX preceding month date filter to a measure

Hi @TD-BI-BNE ,

 

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 other members find it more quickly.

View solution in original post

Helpful resources

Announcements
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Ask Amanda Anything Q&A

Ask Amanda Anything Q&A

Learn the answers to some of the questions asked during the Amanda Triple A event.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Users Online
Currently online: 193 members 2,217 guests
Please welcome our newest community members: