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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Subtract previous month values from current month values using DAX

Hi Experts,

I am working on a scenario like to get the difference of the 2 months and apply into the card based on the month slicer selection.

Example : If i Select May month in the slicer , the values should be May - Apr.

Assume May month value is 39659866 , April month value is 39470667

So the vairance is 189199 (this should be in the card visual).

I don't have any proper date tables in my dashboard.

 

Please help to achieve this asap .. its friday 😞

 

thanks

DK

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I suggest having a proper calendar dimension table.

 

I tried to create a sample pbix file like below.

 

You can try to create table by using below DAX formula after clicking "New Table" button.

 

Jihwan_Kim_0-1720243591123.png

 

And, create a relationship like below.

 

Jihwan_Kim_1-1720243615018.png

 

 

 

Please check the attached pbix file.

 

Jihwan_Kim_2-1720243784997.png

 

OFFSET function (DAX) - DAX | Microsoft Learn

 

 

Sales vs. previous sales: = 
VAR _currentmonth =
    SUM ( sales[sales] )
VAR _previousmonth =
    CALCULATE (
        SUM ( sales[sales] ),
        OFFSET (
            -1,
            ALL ( 'calendar'[Month-Year], 'calendar'[Month-Year sort] ),
            ORDERBY ( 'calendar'[Month-Year sort], ASC )
        )
    )
RETURN
    _currentmonth - _previousmonth

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

I suggest having a proper calendar dimension table.

 

I tried to create a sample pbix file like below.

 

You can try to create table by using below DAX formula after clicking "New Table" button.

 

Jihwan_Kim_0-1720243591123.png

 

And, create a relationship like below.

 

Jihwan_Kim_1-1720243615018.png

 

 

 

Please check the attached pbix file.

 

Jihwan_Kim_2-1720243784997.png

 

OFFSET function (DAX) - DAX | Microsoft Learn

 

 

Sales vs. previous sales: = 
VAR _currentmonth =
    SUM ( sales[sales] )
VAR _previousmonth =
    CALCULATE (
        SUM ( sales[sales] ),
        OFFSET (
            -1,
            ALL ( 'calendar'[Month-Year], 'calendar'[Month-Year sort] ),
            ORDERBY ( 'calendar'[Month-Year sort], ASC )
        )
    )
RETURN
    _currentmonth - _previousmonth

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Anonymous
Not applicable

@Jihwan_Kim  Wowww It saved me a lot 🙂

Thanks for your solution 😍

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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