OFFSET Trouble

Steve 1962

Active Member
Joined
Jan 3, 2006
Messages
349
Office Version
  1. 365
Platform
  1. Windows
Hi

Can't get the OFFSET function to work correctly.

In A2, I want to nominate the amount of moving weeks to use for the average. In this example, I have selected 3 however, weeks 1 & 2 are still showing in cells D4 & D5. With the IFERROR function, they should be blank.

If I was to select 9 in cell A2, then I would expect all cells from D4 to D11 to be blank also.

Thanks

Book1
ABCD
1Weeksx
23x
3WeekxMoving AV
4110.310.4
529.710.4
6311.111.1
7410.6
8510.3
9610.610.6
10710.110.5
11811.110.4
12910.510.3
13109.510.4
Weekly AV (2)
Cell Formulas
RangeFormula
D4:D13D4=IFERROR(AVERAGE(OFFSET($C$3,ROW()-$A$2,0,$A$2,1)),"")
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Hope this helps.
=IF(B4<>$A$2,"",AVERAGE(OFFSET($C$4,0,0,$A$2,1)))
 
Upvote 0
With your formula you want average of 3 weeks down from that cell if week number equal or greater than A2
I think you want this:
Excel Formula:
=IF(B4<$A$2,"",AVERAGE(OFFSET($C$4,0,0,$A$2,1)))
 
Upvote 0
If I place a 1 in cell A2, each of the values in column D should mirror those in column C. They should be the same as it is only a 1 x week moving average. Don't seem to be getting that answer.
 
Upvote 0
Try this:
Excel Formula:
=IFERROR(IF(B4<$A$2,"",AVERAGE(OFFSET($C$3,ROWS($D$3:D3),0,$A$2,1))),"")
 
Upvote 0
Thanks again. Just an observation -

If I select 5 in cell A2, I should be getting the last 5 x week rolling average. If I sample weeks 11 to 15 (over 5 x weeks) in cells C14 to C18, I should get an average of 10.5 in cell D18. The output in cell D18 is 10.3.

Thanks

Book1
ABCD
1Weeksx
25x
3WeekYUB>HGDMoving AV
4110.3 
529.7 
6311.1 
74 
8510.6
9610.610.3
10710.110.4
11811.110.5
12910.510.2
13109.510.1
141110.810.5
151210.810.5
16139.310.3
171410.210.5
181511.310.3
Weekly AV (4)
Cell Formulas
RangeFormula
D4:D18D4=IFERROR(IF(B4<$A$2,"",AVERAGE(OFFSET($C$3,ROWS($D$3:D3),0,$A$2,1))),"")
 
Upvote 0
I tell you Before you see your result at first cell at range
With your formula you want average of 3 weeks down from that cell if week number equal or greater than A2
then you see result of that at D14 not D18.
For that Use this:
Excel Formula:
=IFERROR(IF(B4<$A$2,"",AVERAGE(OFFSET($C$3,ROWS($D$3:D3)-$A$2+1,0,$A$2,1))),"")
 
Upvote 0
Solution
Absolutely PERFECT !!! Thanks Maabadi for your help and patience.

Have a good week.
 
Upvote 0
You're Welcome & thanks for feedback.
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,606
Members
449,089
Latest member
Motoracer88

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