Taking the averaging of the last 3 values.

Cubist

Well-known Member
Joined
Oct 5, 2023
Messages
1,907
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hi,

I have the following sample data. I'm trying to take the averages of the last 3 values in each column. I'm running into an issue when there are less than 3 values in the column (i.e. columns F & G). What I want when that happens, is to average with 1's. For example in column G, I would want to average (1.003239,1,1) = 1.0018.

Simplified Offical IBNR Model...AH-6.xlsb
ABCDEFGH
1ABCDEFG
21.25899911.00153511.00067211.003239
30.9996231.0005081.0013451.0002051.0008041.001393#N/A
41.0005551111#N/A#N/A
51.0086821.0009041.0021061#N/A#N/A#N/A
61.0010631.0056061#N/A#N/A#N/A#N/A
711#N/A#N/A#N/A#N/A#N/A
81#N/A#N/A#N/A#N/A#N/A#N/A
9#N/A#N/A#N/A#N/A#N/A#N/A#N/A
10
11Average of last 31.0003541.002171.0007021.0000681.0004921.0006961.003239
12
13Expected1.0003541.002171.0007021.0000681.0004921.0004641.00108
Sheet1
Cell Formulas
RangeFormula
B11:H11B11=AVERAGE(TAKE(TOCOL(B2:B9,3),-3))
B13:F13B13=AVERAGE(TAKE(TOCOL(B2:B9,3),-3))
G13G13=AVERAGE(G2:G3,1)
H13H13=AVERAGE(1,1,H2)
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
You could use:

Excel Formula:
=AVERAGE(TAKE(VSTACK({1;1},TOCOL(B2:B9,3)),-3))
 
Upvote 0
You could use:

Excel Formula:
=AVERAGE(TAKE(VSTACK({1;1},TOCOL(B2:B9,3)),-3))
That works!

I also want to take the average of the last 6 and 12. Is there a shorter syntax for the 1's array instead of {1;1;1;1;1;1}?
 
Upvote 0
You can use:

Excel Formula:
=AVERAGE(TAKE(VSTACK(SEQUENCE(3,,1,0),TOCOL(B2:B9,3)),-3))

Just change the first argument to SEQUENCE from 3 to 6 or 12.
 
Upvote 0
Solution

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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