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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Creating DAX measures for current and previous calendar month

I'm having trouble with this! 

 

I have a measure to Count unique Invoices where the invoice status is "Submitted". I need this measure for the current reporting month and the previous reporting month. So I am thinking EOMONTH(TODAY()-1) and EOMONTH(TODAY()-2) would work.

 

However, whenever I add the EOMONTH filter, my measure produces entirely the wrong number. When when I add the -2 for Previous Month, it produces an identical figure to Current Month.

 

Any ideas?

 

Claims Current Month = 
CALCULATE(
DISTINCTCOUNT(
'DataMart'[Invoice Id]),
FILTER('DataMart',
'DataMart'[Invoice Status]="SUBMITTED"
&&
MONTH('DataMart'[Invoice Date])=EOMONTH(TODAY(),-1)
))

 

4 REPLIES 4
v-joesh-msft
Solution Sage
Solution Sage

Hi @Anonymous ,

If you only want to calculate the counts of "current month", "last month", "last before month "  by using the Dax, you could try the formula below.

Claims Last Month =
VAR current_month =
    MONTH ( TODAY () )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( 'DataMart'[Invoice Id] ),
        FILTER (
            'DataMart',
            'DataMart'[Invoice Status] = "SUBMITTED"
                && MONTH ( 'DataMart'[Invoice Date] ) = current_month - 1
        )
    )
Claims Last Before Month =
VAR current_month =
    MONTH ( TODAY () )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( 'DataMart'[Invoice Id] ),
        FILTER (
            'DataMart',
            'DataMart'[Invoice Status] = "SUBMITTED"
                && MONTH ( 'DataMart'[Invoice Date] ) = current_month - 2
        )
    )

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

 

Anonymous
Not applicable

I cannot see why this isn't working, I did try a VAR myself with no change to the total, what it's giving me is the grand total but not the total for the month in question. I add a minus two to the end of the measure, and the number doesn't change. 

I have the month split in a matrix so I know what numbers I should be getting. 

I can't upload a sample dataset to this forum as I don't have the option. 

 

Hi @Anonymous ,

You need to have a cloud storage such as Onedrive or Google Drive where you can put your file. After that, you create a shareable link that you can insert in your post enabling people to download the file.

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

amitchandak
Super User
Super User

 think it should be

MONTH('DataMart'[Invoice Date])=Month(EOMONTH(TODAY(),-1))

 

My personal preference is datesmtd. Example

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last MTD (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date Filer],-1,MONTH))))
last year MTD (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date Filer],-12,MONTH))))

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.