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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
elimey
Helper I
Helper I

current month minus previous month in matrix

I have a matrix that looks like this:

elimey_0-1640180284993.png

How can I create another one, in which the value for the current month is equal to the current month - the previous month.  
It means, for example for 30.04.2021 we should have 534-413.

I have used a measure like this:

VAR __PREV_MONTH =
        CALCULATE(
            SUM('Table'[Value]),
            DATEADD('Table'[DSS_START_DATE], -1, MONTH)
        )
    RETURN
    SUM('Table'[Value]) - __PREV_MONTH

But it just works for the last month, i.e. 31.07.2021. For the rest, it shows the same values. 
can someone help?
1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @elimey 

 

You can add a MonthEnd column to Date table, then use this MonthEnd column in the Matrix as Column field. Then use measures

Previous Month Value = CALCULATE(SUM('Table'[Value]),DATEADD(Dates[Date],-1,MONTH))
Diff = SUM('Table'[Value]) - CALCULATE(SUM('Table'[Value]),DATEADD(Dates[Date],-1,MONTH))

21122802.jpg

21122803.jpg

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

3 REPLIES 3
v-jingzhang
Community Support
Community Support

Hi @elimey 

 

You can add a MonthEnd column to Date table, then use this MonthEnd column in the Matrix as Column field. Then use measures

Previous Month Value = CALCULATE(SUM('Table'[Value]),DATEADD(Dates[Date],-1,MONTH))
Diff = SUM('Table'[Value]) - CALCULATE(SUM('Table'[Value]),DATEADD(Dates[Date],-1,MONTH))

21122802.jpg

21122803.jpg

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

amitchandak
Super User
Super User

@elimey , You should always use date table, marked as date table , joined with date of you table  , month year should be use from date table

 

VAR __PREV_MONTH =
CALCULATE(
SUM('Table'[Value]),
DATEADD('Date'[Date], -1, MONTH)
)
RETURN
SUM('Table'[Value]) - __PREV_MONTH

 

Why Time Intelligence Fails - Powerbi 5 Savior Steps for TI : https://youtu.be/OBf0rjpp5Hw

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

with date table I get the same result: 

elimey_0-1640184546873.png

As you can see in the picture above, it just affects the last column, i.e. 31.07.2021, not the rest of the columns.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.