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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
afaro
Helper III
Helper III

Calculating Month on Month Change based on the last aggregations of the current month - previous mon

I have data like this: 

DateIDValue
1 Jan 2020A20
1 Jan 2020B30
10 Jan 2020A40
10 Jan 2020B60
31 Jan 2020A70
31 Jan 2020B80
1 Feb 2020A100
1 Feb 2020B120
28 Feb 2020A300
28 Feb 2020B100
28 Feb 2020C200
31 March 2020F600



First of all, I have data for the different IDs for every single day in the year for many years. (I haven't shown in the table all the days in January or February but I have data for that)

From this data I want to find out 4 changes: Day on Day, Month on Month, Quarter on Quarter, Year on Year 

The day on day change DAX is simple and I have figured that out. 

 

For Month on Month Change, I want the change for month of February to be (300+100+200)-(70+80) = 450 
For March, it would be (600) - (300+100+200) = 0 

Which is basically taking the aggregate on the last date of that month and subtracting it from the aggregate of the last date of the previous month. If it is the current date, then the last date of the month would be current date. 

I prefer not to to create separate summarize tables for this and would prefer to write measures that help me do this. 


@Anonymous @Anonymous @Anonymous @Anonymous @Anonymous 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @afaro ,

 

You can try formula like below:

MEASURE =
VAR cur_ =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            ALL ( 'Table' ),
            MONTH ( 'Table'[Date] ) = MONTH ( MAX ( 'Table'[Date] ) )
                && DAY ( 'Table'[Date] ) = DAY ( ENDOFMONTH ( 'Table'[Date] ) )
        )
    )
VAR pre_ =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            ALL ( 'Table' ),
            MONTH ( 'Table'[Date] )
                = MONTH ( MAX ( 'Table'[Date] ) ) - 1
                && DAY ( 'Table'[Date] ) = DAY ( ENDOFMONTH ( 'Table'[Date] ) )
        )
    )
RETURN
    IF ( MONTH ( MAX ( 'Table'[Date] ) ) <= 1, BLANK (), cur_ - pre_ )

vkongfanfmsft_0-1714614170076.png

 

Best Regards,
Adamk Kong

 

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
Anonymous
Not applicable

Hi  @afaro ,

 

You can try formula like below:

MEASURE =
VAR cur_ =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            ALL ( 'Table' ),
            MONTH ( 'Table'[Date] ) = MONTH ( MAX ( 'Table'[Date] ) )
                && DAY ( 'Table'[Date] ) = DAY ( ENDOFMONTH ( 'Table'[Date] ) )
        )
    )
VAR pre_ =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            ALL ( 'Table' ),
            MONTH ( 'Table'[Date] )
                = MONTH ( MAX ( 'Table'[Date] ) ) - 1
                && DAY ( 'Table'[Date] ) = DAY ( ENDOFMONTH ( 'Table'[Date] ) )
        )
    )
RETURN
    IF ( MONTH ( MAX ( 'Table'[Date] ) ) <= 1, BLANK (), cur_ - pre_ )

vkongfanfmsft_0-1714614170076.png

 

Best Regards,
Adamk Kong

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.