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
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
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.