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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Jmenas
Advocate III
Advocate III

Calculate delta from Month to Month sameperiod

Hi all,

 

I am calculating the delta percentange of my data Month by Month. I use this two measures:

 

 

Past Month:

CALCULATE (SUM('Stock'[unit]),FILTER('Stock',DATEADD('Stock'[dates],-1,MONTH)))

Present Month:

CALCULATE(SUM('Stock'[unit]), FILTER('Stock',DATEADD('Stock'[dates],-0,MONTH)))

 

The problem is regarding the difference Present - Past and then Divide it by the Past then the result doesn't make any sense.

 

 

I know is taking different periods but I can't find a way to make them substrack correctly. I try also with PREVIOUS MONTH and DATEADD (date, -1,Month) but nothing. 

 

Also all my relationship in the model are fine. 

 

here is a screenshot from the graphic

 

 

.Growth.PNG

 

The Last part is the division in from the 1785 and 2493 

Thanks,

Jorge

1 ACCEPTED SOLUTION
Sean
Community Champion
Community Champion

Okay I just noticed you are not referencing a Calendar Table with DATEADD

 

DATEADD requires contiguous date selection like in a Calendar Table

"The Main reason why a Date Table should include all days within a year is because of DATEADD behavior"

The Definitive Guide to DAX page 194

 

Change Past Month to this instead

Past Month =
CALCULATE ( SUM ( 'Stock'[unit] ), PREVIOUSMONTH ( 'Stock'[dates].[date] ) )

Now because you are plotting on an X-Axis - Year Month (you can do this to quickly see)

 

MoM % Change =
DIVIDE ( SUM ( 'Stock'[unit] ) - [Past Month], [Past Month], 0 )

Hope this helps!

Good Luck!

View solution in original post

5 REPLIES 5
Sean
Community Champion
Community Champion

The formulas seem fine and should work!

Except this maybe a typo but just in case

in the 1st you are referencing column [units] in the second [unit] are those different columns?

@Sean Thanks for the correction, It was unit. Should work fine but if you see the data the difference is not fine I seem to get a difference range of dates and that makes the  worng difference between the months.

 

Sean
Community Champion
Community Champion

Okay I just noticed you are not referencing a Calendar Table with DATEADD

 

DATEADD requires contiguous date selection like in a Calendar Table

"The Main reason why a Date Table should include all days within a year is because of DATEADD behavior"

The Definitive Guide to DAX page 194

 

Change Past Month to this instead

Past Month =
CALCULATE ( SUM ( 'Stock'[unit] ), PREVIOUSMONTH ( 'Stock'[dates].[date] ) )

Now because you are plotting on an X-Axis - Year Month (you can do this to quickly see)

 

MoM % Change =
DIVIDE ( SUM ( 'Stock'[unit] ) - [Past Month], [Past Month], 0 )

Hope this helps!

Good Luck!

Anahita
Frequent Visitor

HI, I have same problem and I,m using similare formula as below:

 

OTE Last Month = CALCULATE([AVG OTE Score], PREVIOUSMONTH('OTE-FCR'[INTERACTION_DATE (-06:00 GMT)].[Date]))

 

but the result above formula returns is zero! I can't understand why?! 

Do you see any errors?

Thanks a lot

@Sean Totally right! then I did something different just take out the filter because it was creating a conflict. But yes thank you! I didn't know that DATEADD was rigourus about the dates! 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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