# past 6 weeks average SAP IBP

Dear all,

I am trying to calculate the average last 6 weeks of KF1 (at level WKRESLOC) and show in the current period at KF2 (also at WKRESLOC).

I am doing these calculations, please let me know if it is right:

1) Extract the values from KF1:

KF1@wkresloc = IF(("\$\$PERIODIDCU\$\$"-PERIODID<=6)AND(PERIODID- "\$\$PERIODIDCU\$\$">=0),"KF1@resloc",NULL) ???

2) Sum the 6 values:

KF1@resloc = SUM (KF1@wkresloc)

3) Create helper KF:

HKF1@resloc = KF1@resloc/6

4) Put avg value in current period of KF2:

HKF1@wkresloc = IF ((PERIODID=\$\$PERIODIDCU\$\$, HKF1@resloc, NULL)

5) Show result it in KF2:

KF2@wkresloc = HKF1@wkresloc

Thanks for letting me know if this should be right, specially the PERIODID and \$\$PERIODIDCU\$\$ part of it.

Best regards.

10|10000 characters needed characters exceeded

Feb 16, 2017 at 04:51 PM

Hi,

This seems correct.

You may refer below thread as well-

Thanks,

Rohit

10|10000 characters needed characters exceeded
• Mar 17, 2017 at 05:31 PM

Hello Juancarlos,

After analyzing your request and recreating the scenario in my internal system, I was able to achieve the behavior according to note 2240170. This note explains how to configure a Key Figure with the rolling Sum of the last 3 periods but you can adapt it to 6 periods, using Average and without considering the current period.

After reviewing the PDF file attached in the note, please consider the following adaptations:

- you have 6 additional Planning Levels for WKRESLOC, i.e. WKRESLOC1, WKRESLOC2 and so on;
- for the Attribute Transformations (e.g. PERIODID, PERIODID0 and so on) you need to configure 6 calculations: “PERIODID0” + 1; “PERIODID0” + 2; until + 6;
- for the Helper Key Figures, follow the logic of KFs HACTUAL1 and HACTUAL2 of the PDF file;
- when you create the KF that will store the average of last 6 periods, use the following logic of calculation: (“HACTUAL1@REQUEST” + “HACTUAL2@REQUEST” + “HACTUAL3@REQUEST” + “HACTUAL4@REQUEST” + “HACTUAL5@REQUEST” + “HACTUAL6@REQUEST” +) / 6

Best regards,
Matheus Korndoerfer
SAP Product Support

10|10000 characters needed characters exceeded
• Feb 17, 2017 at 05:00 PM

Hello Rohit,

I am trying with these calculations taken form the community where you mentioned, but without success...

Specially I can't reproduce exactly that, as some of the calculations give me an errors saying the planning level on the right should match with the planning level on the left. (but in the community article are different!)

Am I missing something in the steps or anything must be changed?

Many thanks!