Average Last 5 in row, excluding blanks

chrisb182

New Member
Joined
Mar 3, 2022
Messages
35
Office Version
  1. 2016
Platform
  1. Windows
Hi All,

I've seen many answers to this question on here but none of them are working for my spready.

Basically I want to average the last 5 numbers in a row, excluding any blanks.

Here's a screenshot of some numbers I'm working with, with the expected result.

If someone could help, I'd be immensely grateful!

Cheers,

Chris

1669120493896.png
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
This one should work:

Excel Formula:
=AVERAGEIF(O3:INDIRECT(ADDRESS(3,COLUMN(O3)-4)),"<>0",O3:INDIRECT(ADDRESS(3,COLUMN(O3)-4)))


sequence_average_payments_52weeks.xlsx
CWCXCYCZDADBDC
1
2
3012.907.717.212.6
4
Sheet1
Cell Formulas
RangeFormula
DC3DC3=AVERAGEIF(DA3:INDIRECT(ADDRESS(3,COLUMN(DA3)-4)),"<>0",DA3:INDIRECT(ADDRESS(3,COLUMN(DA3)-4)))
 
Upvote 0
This one should work:

Excel Formula:
=AVERAGEIF(O3:INDIRECT(ADDRESS(3,COLUMN(O3)-4)),"<>0",O3:INDIRECT(ADDRESS(3,COLUMN(O3)-4)))


sequence_average_payments_52weeks.xlsx
CWCXCYCZDADBDC
1
2
3012.907.717.212.6
4
Sheet1
Cell Formulas
RangeFormula
DC3DC3=AVERAGEIF(DA3:INDIRECT(ADDRESS(3,COLUMN(DA3)-4)),"<>0",DA3:INDIRECT(ADDRESS(3,COLUMN(DA3)-4)))
Hi mate,

I'm afraid that's not working. I entered that formula (replacing DA3 with O3) and it comes out with 17.93 for your example above.
 
Upvote 0
Hi, not sure to understand - when you say my example above - the 12.6 is the answer which was in your example (thus so you can see it works for last 5 values (or 3 actually in this case).

The formula you can see in DC3 from the sheet above is slightly different, as you said from the one I suggested for your numbers which start in Col O and count backwards.

Which data are you using to get 17.93 can I ask ?

thanks
ROb
(keep in mind the ADDRESS no."3" in the formula refers to Row 3 - which is where I had it in my example. Sorry, you might need to change it to "4" as below)

Excel Formula:
=AVERAGEIF(O3:INDIRECT(ADDRESS(4,COLUMN(O3)-4)),"<>0",O3:INDIRECT(ADDRESS(4,COLUMN(O3)-4)))
The -4 inside means count back 4 steps. eg. take last 5 cols of data)
 
Upvote 0
Hi, not sure to understand - when you say my example above - the 12.6 is the answer which was in your example (thus so you can see it works for last 5 values (or 3 actually in this case).

The formula you can see in DC3 from the sheet above is slightly different, as you said from the one I suggested for your numbers which start in Col O and count backwards.

Which data are you using to get 17.93 can I ask ?

thanks
ROb
(keep in mind the ADDRESS no."3" in the formula refers to Row 3 - which is where I had it in my example. Sorry, you might need to change it to "4" as below)

Excel Formula:
=AVERAGEIF(O3:INDIRECT(ADDRESS(4,COLUMN(O3)-4)),"<>0",O3:INDIRECT(ADDRESS(4,COLUMN(O3)-4)))
The -4 inside means count back 4 steps. eg. take last 5 cols of data)
Ahhh OK. That makes sense. Changing the ADDRESS to '4' does work to get the 12.6 figure.:)

Bearing in mind I have 500+ rows to maintain and I'll have to drag the formula down, is there anyway for the ADDRESS to change automatically to correspond with whatever Row the formula is on?
 
Upvote 0
ouch .. yes.. instead of the "3" - replace with ROW() - as this will give you the current row number. Let me know if it works.
 
Upvote 0
How about
Fluff.xlsm
DEFGHIJKLMNOAO
1
200000020.333.913.619.818.121.1
3000000012.907.717.212.6
4486112213592801714.4
534.917.317.123.430.519.626.9032.131.127.527.4
Data
Cell Formulas
RangeFormula
AO2:AO5AO2=IFERROR(AVERAGEIFS(O2:INDEX(D2:O2,AGGREGATE(14,6,SEQUENCE(,12)/(D2:O2<>0),5)),O2:INDEX(D2:O2,AGGREGATE(14,6,SEQUENCE(,12)/(D2:O2<>0),5)),"<>0"),AVERAGEIFS(D2:O2,D2:O2,"<>0"))
 
Upvote 0
@RobP - Good news: The ROW() part of the formula works fine. :) Unfortunately, it didn't work for all the rows.

@Fluff - That formula works great. Thank you very much! (y)(y):giggle:

I really appreciate both of your replies!
 
Upvote 0
Just realised I left the sequence function in, which doesn't exist in xl2016, so are you using a newer version of xl? If so what?
 
Upvote 0

Forum statistics

Threads
1,215,036
Messages
6,122,794
Members
449,095
Latest member
m_smith_solihull

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