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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
elimey
Frequent Visitor

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

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.