Average of Last 3 values in range

Bradleeyb13

New Member
Joined
May 20, 2023
Messages
16
Office Version
  1. 2019
Platform
  1. Windows
I would like to find the average of the last 3 values in a certain range (rows) D3:AX3, this range will have many blank cells scatter between values and I would like to find the average for the last 3 values input into that range
 
All the values that look like numbers in your post #14 sample come across from XL2BB as actual numbers. Does that mean that XL2BB has coerced them to numbers or is that data not representative of your actual "mixed" data?
If not representative, can you post some with XL2BB that is representative?
When I ran “=isnumber” on individual cellsI found mixed results, when running on the range (B2:T2) as a whole it came back as “FALSE”.
after using “text to columns” on all columns I again ran “=isnumber” on all individual cells and they all came back “TRUE” although the formula still didn’t work?
 
Upvote 0

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
When I ran “=isnumber” on individual cellsI found mixed results,
That did not really address my question about whether XL2BB changed the nature of your sample data or not.

Was the sample data in post 14 produced from a mixture of True/False ISNUMBER data, or was the original data in that case all ISNUMBER True before you used XL2BB?
To be able to investigate the best way forward, I would want to get hold of some actual 'mixed' data so I can determine just what it is that is causing ISNUMBER to return False in some cells.
 
Upvote 0
That did not really address my question about whether XL2BB changed the nature of your sample data or not.

Was the sample data in post 14 produced from a mixture of True/False ISNUMBER data, or was the original data in that case all ISNUMBER True before you used XL2BB?
To be able to investigate the best way forward, I would want to get hold of some actual 'mixed' data so I can determine just what it is that is causing ISNUMBER to return False in some cells.
I think I was able to find an issue, below is an updated sheet where on the right hand side I have done an "=ISNUMBER" test on all relevant cells, the first row I have replaced the blanks with "0" and they all return back as "TRUE", the second row all cells in the range were filled anyway so all return "TRUE". The third row has a mix of numbers and blanks, with the blanks left they are the cells returning as "FALSE".

Is there a way to add an excluding "0" to this formula? =AVERAGE(INDEX(B2:T2,1,LARGE(IF(B2:T2<>"",COLUMN(B2:T2)-COLUMN(B2)+1),MIN(3,COUNT(B2:T2)))):T2)

I would have thought the 0s would have been included within the last 3 average and the average for the first row would become 4 (12 / 3) but it is still showing the "#VALUE!"

I have also placed this formula in with the "#VALUE!" error underneath "3GM AVG"

Hope this helps!

Disposals Auto 2023.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAO
1PlayerR1R2R3R4R5R6R7R8R9R10R11R12R13R14R16R17R18R19R20Tot3GM AVGBCDEFGHIJKLMNOPQRST
2Baker, Oskar131318201115201515201522414000120227#VALUE!TRUETRUETRUETRUETRUETRUETRUETRUETRUETRUETRUETRUETRUETRUETRUETRUETRUETRUETRUE
3Bontempelli, Marcus25242825233119322530272331322729312927518#VALUE!TRUETRUETRUETRUETRUETRUETRUETRUETRUETRUETRUETRUETRUETRUETRUETRUETRUETRUETRUE
4Bruce, Josh141711148106383#VALUE!TRUETRUETRUETRUETRUEFALSEFALSEFALSEFALSEFALSEFALSEFALSETRUEFALSEFALSEFALSEFALSETRUETRUE
WB
Cell Formulas
RangeFormula
V2:V4V2=AVERAGE(INDEX(B2:T2,1,LARGE(IF(B2:T2<>"",COLUMN(B2:T2)-COLUMN(B2)+1),MIN(3,COUNT(B2:T2)))):T2)
W2:AO4W2=ISNUMBER(B2)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
1:1,5:1048576,A2:U4,W2:XFD4Cell Valuecontains "Y E S"textNO
1:1,5:1048576,A2:U4,W2:XFD4Cell Valuecontains "Yes"textNO
1:1,5:1048576,A2:U4,W2:XFD4Cell Valuebeginning with "No"textNO
1:1,5:1048576,A2:U4,W2:XFD4Cell Value<0textNO
1:1,5:1048576,A2:U4,W2:XFD4Cellcontains a blank value textNO
1:1,5:1048576,A2:U4,W2:XFD4Cellcontains an errortextNO
 
Upvote 0
he third row has a mix of numbers and blanks, with the blanks left they are the cells returning as "FALSE".
Well, you would expect blank cells to return FALSE, since a blank is not a number.

I think XL2BB is changing the data since when I copy your mini sheet to my blank sheet, the formulas in column V are automatically returning the correct answers.
4 for row 2 as you described above (0+0+12)/3
29 for row 3 (31+29+27)/3
6.333 for row 4 (10+6+3)/3

What do each of these formulas return if you put them in some blank cells, noting that R4 is one of the 'blank' cells?
=LEN(R4)
=CHAR(R4)
=R4=""
 
Upvote 0
Well, you would expect blank cells to return FALSE, since a blank is not a number.

I think XL2BB is changing the data since when I copy your mini sheet to my blank sheet, the formulas in column V are automatically returning the correct answers.
4 for row 2 as you described above (0+0+12)/3
29 for row 3 (31+29+27)/3
6.333 for row 4 (10+6+3)/3

What do each of these formulas return if you put them in some blank cells, noting that R4 is one of the 'blank' cells?
=LEN(R4)
=CHAR(R4)
=R4=""
What do each of these formulas return if you put them in some blank cells, noting that R4 is one of the 'blank' cells?
=LEN(R4) - "0"
=CHAR(R4) - "#VALUE!"
=R4="" - "TRUE"
 
Upvote 0
Thanks for the formula returns. However, that means I cannot tell why the formula I suggested is not working.

Are you able to upload a small sample file where the column V formula is not working (with any sensitive data disguised or removed) to one of DropBox, OneDrive, Google Drive etc and post a publicly shared link here so that I can take a look at an actual problem workbook?

Edit: Oops perhaps I do know what the problem is. What happens if you edit the V2 formula and confirm with Ctrl+Shift+Enter, not just Enter and then copy down?
 
Upvote 0
Thanks for the formula returns. However, that means I cannot tell why the formula I suggested is not working.

Are you able to upload a small sample file where the column V formula is not working (with any sensitive data disguised or removed) to one of DropBox, OneDrive, Google Drive etc and post a publicly shared link here so that I can take a look at an actual problem workbook?

Edit: Oops perhaps I do know what the problem is. What happens if you edit the V2 formula and confirm with Ctrl+Shift+Enter, not just Enter and then copy down?
Oh wow yes that actually works!

Thankyou so much!
May I just ask why that happens and what doing Ctrl+Shift+Enter means?
 
Upvote 0
Ctrl+Shift+Enter makes the formula into an 'array formula' so that it processes calculation(s) on all the values in an array not just one. Some more information and examples here.
With Microsoft 365, which I use, there is no longer a need to use Ctrl+Shift+Enter which is why I forgot about it for your version (& often do :()

Anyway, glad we got there in the end. :)
 
Upvote 0
Ctrl+Shift+Enter makes the formula into an 'array formula' so that it processes calculation(s) on all the values in an array not just one. Some more information and examples here.
With Microsoft 365, which I use, there is no longer a need to use Ctrl+Shift+Enter which is why I forgot about it for your version (& often do :()

Anyway, glad we got there in the end. :)
Thanks heaps!
You are the best and I will mark this as finsihed!
Hopefully one day I can wrap my head around excel as much as you can!

Thanks again :)
 
Upvote 0
You are very welcome. Thanks for your kind comments.

I must be getting a little tired/confused. Looking back over the thread, although I did not specifically mention it in my text, I had included the fact that the formula needed to be confirmed with Ctrl+Shift+Enter. See this from post #15 (it was similarly shown in post #2)

1690891278922.png


I have therefore changed the 'Mark as solution' to post #15. :)
 
Upvote 0

Forum statistics

Threads
1,215,048
Messages
6,122,862
Members
449,097
Latest member
dbomb1414

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