Moving average

gravanoc

Active Member
Joined
Oct 20, 2015
Messages
351
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
I'm trying to create a formula that shows the remaining forecast values for a certain time period based on how the actual values are inputted each day.

In my setup I have approx. a full calendar year in column C11:C358, the forecast is in E6, the sum of the actuals in F11:F353 (where they fall between the correct dates) is in F6, the start date is in E7, and the end date is in E8.
An example: Forecast value is 15,288, start date is 1/25/2022, and end date is 3/15/2022. That's a 49 day time period, but I add +1 to make it inclusive, so it's 50. In E11:E358 I have a formula that checks if the adjacent dates are within the start & end date, and if so, I divide the forecast by the days. That is, 15,288 / 50 = 306.75.

The next part is where I'm having trouble, since if I change the logic so that the actuals are subtracted from the forecast and their difference is divided by the days, then it will adjust the remaining days downward. For example, if I input 306 as an actual value next to the first forecast value in the column, then the remaining values will average to 300. Unfortunately, it will always decrease the average if the value is positive. If I enter a number less than one of the forecast values then the remaining forecast values should increase.

Here is a screenshot to help visualize. XL2BB below.
1660764178092.png


Cell Formulas
RangeFormula
D2D2=Sheet1!B5 & " [Forecast QTY: " & TEXT(SUM(E6,G6,I6,K6,M6),"#,##0") & " Actual QTY: " & TEXT(SUM(F6,H6,J6,L6,N6),"#,##0") & "]"
E5E5=E6/E4
E6E6=Sheet1!D5
F6F6=SUMIFS(F$11:F$358,$C$11:$C$358,">="&E$7,$C$11:$C$358,"<="&E$8)
D11:D21D11=IF(SUM(E11:M11)=0,,ROUND(SUM(E$11:M11),2))
E11:E21E11=IF(OR(F11=0,F11=""),IF(AND($C11<=E$8,$C11>=E$7),SUM((E$6-F$6)/SUM(E$8-E$7+1)),""),0)
C12:C21C12=C11+1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C11:C358Expression=$C11=CODdatetextNO
C11:C358Expression=$C11=IADdatetextNO
C11:C358Expression=COUNTIF(Holidays,#REF!)textNO
C11:C358Expression=OR(WEEKDAY(C11)=1,WEEKDAY(C11)=7)textNO
C11:C358Expression=OR(WEEKDAY(#REF!)>1,WEEKDAY(#REF!)<7)textYES
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Check if this is what you were looking for -

It took me quite some time to understand what you probably wanted and where things were going wrong. Still until you verify everything is an assumption for me.

Also note, I have changed dates to numbers to create uniformity because dates in your part of the world and in my are are presented differently.

All Records.xlsb
CDEF
2 [Forecast QTY: 15,288 Actual QTY: 306]
3SubprojectS1
4MWac50
5Q/MWac305.76
6Forecast / Actual Qty15288306
7Start44,586
8Finish44,635
9
10DatesRunning TotalForecast RemainingActual Values
1144,5810 
1244,5820 
1344,5830 
1444,5840 
1544,5850 
1644,5863060306
1744,587611.76305.76
1844,588923.89312.13
1944,5891242.66318.77
2044,5901568.36325.7
2144,5911901.29332.93
Sheet1
Cell Formulas
RangeFormula
D2D2=Sheet1!B5 & " [Forecast QTY: " & TEXT(SUM(E6,G6,I6,K6,M6),"#,##0") & " Actual QTY: " & TEXT(SUM(F6,H6,J6,L6,N6),"#,##0") & "]"
E5E5=E6/E4
F6F6=SUMIFS(F$11:F$358,$C$11:$C$358,">="&E$7,$C$11:$C$358,"<="&E$8)
D11:D21D11=IF(SUM(E11:M11)=0,,ROUND(SUM(E$11:M11),2))
E11:E21E11=IF(OR(F11=0,F11=""),IF(AND($C11<=$E$8,$C11>=$E$7),ROUND(($E$6-$F$6)/SUM($E$8-C11+1),2),""),0)
C12:C21C12=C11+1
 
Upvote 0
Solution

Forum statistics

Threads
1,223,908
Messages
6,175,306
Members
452,633
Latest member
DougMo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top