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

View all the Fabric Data Days sessions on demand. View schedule

Reply
Anonymous
Not applicable

Create Measure that calculates sum for current month and previous month

Hi, 

 

I have a table with the column Date that goes on for 12 months, let's say and Total Amount. I would like to create two different measures: one that will always show me the sum of the Current Month, and another measure that gives me the sum of the Previous Month.

 

I create a Measure using calculate and sum, but it was empty.

 

Thanks for your help.

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Anonymous , We can use time intelligence with date table.

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 month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))
last MTD (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-1,MONTH))))
previous month value =  CALCULATE(sum('table'[total hours value]),previousmonth('Date'[Date]))

diff = [MTD Sales]-[last MTD Sales]
diff % = divide([MTD Sales]-[last MTD Sales],[last MTD Sales])

 

 

Power BI — MTD
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-YTD-LYTD-Week-Over-Week/m-p/1051626#M184


Appreciate your Kudos.

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

View solution in original post

danextian
Super User
Super User

Hi @Anonymous,

The answer will depend on how you define current and previous month - are they based on today's date or on the slicer selection? Here's my take on this  assuming that current month is based on the slicer selection.
Create these measures:

Previous Month Start - Current Filter Context = 
EOMONTH ( MAX ( 'Table'[Date] ), -2 ) + 1

Previous Month End - Current Filter Context = 
EOMONTH ( MAX ( 'Table'[Date] ), -1 )

Current Month Start - Current Filter Context = 
EOMONTH ( MAX ( 'Table'[Date] ), -1 ) + 1

Current Month End - Current Filter Context = 
EOMONTH ( MAX ( 'Table'[Date] ), 0 )

Previous Month's Value = 
CALCULATE (
    SUM ( 'Table'[Value] ),
    DATESBETWEEN (
        'Table'[Date],
        [Previous Month Start - Current Filter Context],
        [Previous Month End - Current Filter Context]
    )
)

Current Month's Value = 
CALCULATE (
    SUM ( 'Table'[Value] ),
    DATESBETWEEN (
        'Table'[Date],
        [Current Month Start - Current Filter Context],
        [Current Month End - Current Filter Context]
    )
)


 

Change MAX ( 'Table'[Date] ) to TODAY() if current month is based on the current date.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

2 REPLIES 2
danextian
Super User
Super User

Hi @Anonymous,

The answer will depend on how you define current and previous month - are they based on today's date or on the slicer selection? Here's my take on this  assuming that current month is based on the slicer selection.
Create these measures:

Previous Month Start - Current Filter Context = 
EOMONTH ( MAX ( 'Table'[Date] ), -2 ) + 1

Previous Month End - Current Filter Context = 
EOMONTH ( MAX ( 'Table'[Date] ), -1 )

Current Month Start - Current Filter Context = 
EOMONTH ( MAX ( 'Table'[Date] ), -1 ) + 1

Current Month End - Current Filter Context = 
EOMONTH ( MAX ( 'Table'[Date] ), 0 )

Previous Month's Value = 
CALCULATE (
    SUM ( 'Table'[Value] ),
    DATESBETWEEN (
        'Table'[Date],
        [Previous Month Start - Current Filter Context],
        [Previous Month End - Current Filter Context]
    )
)

Current Month's Value = 
CALCULATE (
    SUM ( 'Table'[Value] ),
    DATESBETWEEN (
        'Table'[Date],
        [Current Month Start - Current Filter Context],
        [Current Month End - Current Filter Context]
    )
)


 

Change MAX ( 'Table'[Date] ) to TODAY() if current month is based on the current date.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
amitchandak
Super User
Super User

@Anonymous , We can use time intelligence with date table.

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 month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))
last MTD (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-1,MONTH))))
previous month value =  CALCULATE(sum('table'[total hours value]),previousmonth('Date'[Date]))

diff = [MTD Sales]-[last MTD Sales]
diff % = divide([MTD Sales]-[last MTD Sales],[last MTD Sales])

 

 

Power BI — MTD
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-YTD-LYTD-Week-Over-Week/m-p/1051626#M184


Appreciate your Kudos.

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

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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