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
Doorian
New Member

DAX Measure

Hello everyone, I am looking for help regarding a DAX measure in a matrix visual. I want to calculate the change of my initial measure (number of trips per day) compared to the previous month. In my matrix visual, I include the month and year (MM-YYYY) in the columns, the change is calculated correctly for each month, however, the calculation on the total is not correct. Would you know how to ensure that the total change is from the oldest month to the most recent month in the matrix? Thank you.

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

You can try

Month on Month change =
IF (
    ISINSCOPE ( 'Date'[Year month] ),
    VAR CurrentValue = [Num trips]
    VAR PrevValue =
        CALCULATE ( [Num trips], DATEADD ( 'Date'[Date], -1, MONTH ) )
    VAR Result = CurrentValue - PrevValue
    RETURN
        Result,
    VAR MinDate =
        MINX (
            ALLSELECTED ( 'Date'[Year month sort column] ),
            'Date'[Year month sort column]
        )
    VAR MaxDate =
        MAXX (
            ALLSELECTED ( 'Date'[Year month sort column] ),
            'Date'[Year month sort column]
        )
    VAR CurrentValue =
        CALCULATE ( [Num trips], 'Date'[Year month sort column] = MaxDate )
    VAR PrevValue =
        CALCULATE ( [Num trips], 'Date'[Year month sort column] = MinDate )
    VAR Result = CurrentValue - PrevValue
    RETURN
        Result
)

Its important to use the column which year month is sorted by, rather than the year month column itself, as MIN / MAX won't work properly with alphanumeric columns. If your year month column is actually date which is just formatted in year month format then you can use that column.

View solution in original post

4 REPLIES 4
v-venuppu
Community Support
Community Support

Hi @Doorian ,

I hope this information is helpful. Please let me know if you have any further questions or if you'd like to discuss this further. If this answers your question, please accept it as a solution and give it a 'Kudos' so other community members with similar problems can find a solution faster.

Thank you.

v-venuppu
Community Support
Community Support

Hi @Doorian ,

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.

Thank you.

v-venuppu
Community Support
Community Support

Hi @Doorian ,

Thank you for reaching out to Microsoft Fabric Community.

Thank you @johnt75 for the prompt response.

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

johnt75
Super User
Super User

You can try

Month on Month change =
IF (
    ISINSCOPE ( 'Date'[Year month] ),
    VAR CurrentValue = [Num trips]
    VAR PrevValue =
        CALCULATE ( [Num trips], DATEADD ( 'Date'[Date], -1, MONTH ) )
    VAR Result = CurrentValue - PrevValue
    RETURN
        Result,
    VAR MinDate =
        MINX (
            ALLSELECTED ( 'Date'[Year month sort column] ),
            'Date'[Year month sort column]
        )
    VAR MaxDate =
        MAXX (
            ALLSELECTED ( 'Date'[Year month sort column] ),
            'Date'[Year month sort column]
        )
    VAR CurrentValue =
        CALCULATE ( [Num trips], 'Date'[Year month sort column] = MaxDate )
    VAR PrevValue =
        CALCULATE ( [Num trips], 'Date'[Year month sort column] = MinDate )
    VAR Result = CurrentValue - PrevValue
    RETURN
        Result
)

Its important to use the column which year month is sorted by, rather than the year month column itself, as MIN / MAX won't work properly with alphanumeric columns. If your year month column is actually date which is just formatted in year month format then you can use that column.

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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.