# Forecasting Seasonal Data using powerpivot



## Mavericks334 (Dec 6, 2012)

Hi,

How to create a seasonal index for each month, which could be used to forecast using it in combination with historical data either with Linear or exponential forecasting.

Regards,
Renato.


----------



## Jacob Barnett (Dec 6, 2012)

There are endless possibilities in terms of the minutiae of how you would want to perform the calculation but ALL() in CALCULATE() is the technique you are probably looking for.

On the basis that you have a measure called [Sales] and the time period  month number comes from a table called calendar:


```
[Seasonal Index] = [Sales] / CALCULATE([Sales],ALL(Calendar[Month Number]))
```

There are two caveats:

 - You will need to put a further time restriction in your second calculate, probably to only include full completed years.

 - It may behave strangely in grand totals so depending on how you intend to use it you could package it like this:


```
[Seasonal Index] = if ( HASONEVALUE(Calendar[Month Number]), [Sales] / CALCULATE([Sales],ALL(Calendar[Month Number])), BLANK())
```

On the downside that would stop your [Seasonal Index] measure 'magically' working if you decided to use it at a higher level e.g. Quarterly.

Hope this helps.
Jacob


----------



## Mavericks334 (Dec 7, 2012)

Hi Jacob,

I have tried the above suggested measures, i get 1 for all the measures, as the seasonal index.

Regards,
Renato.


----------



## Mavericks334 (Dec 7, 2012)

Forgot to create a relationship, not it works gr8


----------



## Mavericks334 (Dec 7, 2012)

The Problem, now is that if i had current fiscal years data, it takes that numbers as well. How that could be avoided. i tried to use

CALCULATE([Sales],ALL(Calendar[Month Number]),Year< [Max Year]),

Where MAx year is the year from the slicer


----------



## Mavericks334 (Dec 7, 2012)

The Seasonal index changes when i select a year in the slicer and gives me that year seasonal index, who could i see that the slicer does not effect the seasonal index except where it takes the data from the years lesser than Max year selected


----------



## Jacob Barnett (Dec 7, 2012)

Sorry, it was never going to work properly without ALL() on more than just the Month Number.

On a basic level this works:

[Seasonal Index] = [Sales] / CALCULATE([Sales],ALL(Calendar))

It becomes slightly more complex if you then want to use a slicer to specify the years to use. Two questions:

 - What is the purpose of the model? Is it to use this measure as part of a wider PowerPivot based tool or is it purely to derive the seasonal index?
 - Is the slicer part of the calendar table?


----------



## Mavericks334 (Dec 7, 2012)

Yes, it helps me select the year that i wish to forecast data for. So when i select the year in the slicer it creates a seasonal index for that particular year, not the historical years.


----------



## Jacob Barnett (Dec 7, 2012)

This will do it, has to have something like month number in the rows or columns and needs to be filtered by a 'Year'

=CALCULATE([Sales],
    FILTER(ALL(Calendar[Calendar Year]),Calendar[Calendar Year]<values(calendar[calendar year])))
        /
  CALCULATE([Sales],
    FILTER(ALL(Calendar),Calendar[Calendar Year]<values(calendar[calendar year])))


BTW, I've no idea why you've posted that other question that is clearly part of this thread. Its pretty bad form!</values(calendar[calendar></values(calendar[calendar>


----------



## Mavericks334 (Dec 7, 2012)

The Other question, is where i would use the values from that, to multiply with the seasonal index that i get from this question. So total two different questions


----------



## Mavericks334 (Dec 6, 2012)

Hi,

How to create a seasonal index for each month, which could be used to forecast using it in combination with historical data either with Linear or exponential forecasting.

Regards,
Renato.


----------



## Mavericks334 (Dec 7, 2012)

Jacob Barnett said:


> Sorry, it was never going to work properly without ALL() on more than just the Month Number.
> 
> On a basic level this works:
> 
> ...




Hi Jacob,

I still get the seasonal index as 1 for all the months.

=CALCULATE([Value_Corrected],FILTER(ALL(Year[Year]),Year[Year]<VALUES(Year[Year])))/CALCULATE([Value_Corrected],FILTER(ALL(Year),Year[Year]<VALUES(Year[Year])))

Measure that i am using.


----------



## Jacob Barnett (Dec 7, 2012)

Think your last post got cut off.....

The stuff I've sent _should _work as I've tested it. The only way to make progress if for you to send me some kind of sample workbook, I've PM'd you my email.

Jacob


----------



## Mavericks334 (Dec 12, 2012)

Jacob Barnett said:


> Think your last post got cut off.....
> 
> The stuff I've sent _should _work as I've tested it. The only way to make progress if for you to send me some kind of sample workbook, I've PM'd you my email.
> 
> Jacob



=CALCULATE([Value_Corrected],FILTER(ALL(Year[Year]),Year[Year]<VALUES(Year[Year])))/CALCULATE([Value_Corrected],FILTER(ALL(Year),Year[Year]<VALUES(Year[Year])))
The above measure is what i have used. Unfortunately i cannot send the file.

When i create two seperate measures and check the values they are identical. [Value_corrected] is a measure that sums up all the data.

Year is the table where i have the years listed from 2008 and also i am using the same data to create a slicer


----------



## theresabetterway (Aug 17, 2015)

Jacob Barnett said:


> This will do it, has to have something like month number in the rows or columns and needs to be filtered by a 'Year'
> 
> =CALCULATE([Sales],
> FILTER(ALL(Calendar[Calendar Year]),Calendar[Calendar Year]<values(calendar[calendar year])))
> ...


----------



## Mavericks334 (Aug 24, 2015)

Thanks could you share a sample file for the same. Would like to see how it works.


----------

