## Desktop

Member
Posts: 74
Registered: ‎11-19-2016

# Calculate delta from Month to Month sameperiod

[ Edited ]

Hi all,

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

```Past Month:

Present 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

.

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

Thanks,

Jorge

Accepted Solutions
Super User
Posts: 2,146
Registered: ‎08-11-2015

## Re: Calculate delta from Month to Month sameperiod

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!

All Replies
Super User
Posts: 2,146
Registered: ‎08-11-2015

## Re: Calculate delta from Month to Month sameperiod

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?

Member
Posts: 74
Registered: ‎11-19-2016

## Re: Calculate delta from Month to Month sameperiod

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

Super User
Posts: 2,146
Registered: ‎08-11-2015

## Re: Calculate delta from Month to Month sameperiod

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!

Member
Posts: 74
Registered: ‎11-19-2016

## Re: Calculate delta from Month to Month sameperiod

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

Highlighted
Frequent Visitor
Posts: 8
Registered: ‎07-09-2018

## Re: Calculate delta from Month to Month sameperiod

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