Formula to work out average value from a range of cells containing some blanks

Jonny_71

New Member
Joined
Sep 12, 2017
Messages
12
Office Version
  1. 365
Hi,

I need to know a formula which will work out an average based on the following:

- Row A represents game weeks (e.g. week 1, week 2, etc.)
- Week 6 is the most recent week, week 5 is the next most recent week, etc.
- Row B represents points scored in each game week, e.g. week 6 = 5 points, week 5 = 0 points, etc.
- The blank values (e.g. week 4 and week 2) there was no game

I need the formula to calculate the average points scored in the three most recent weeks where there has been a game, e.g. the formula would need to calculate the average of weeks 6, 5 and 3 in the example below, i.e. (5 + 0 + 1)/3 = 2 points.


654321
50 1 8

<colgroup><col span="6"></colgroup><tbody>
</tbody>

I'm struggling with this. Many thanks for your help.
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Welcome to the forum.

Maybe:

=AVERAGE(OFFSET(A2,0,0,1,SMALL(IF(A2:F2<>"",COLUMN(A2:F2)),3)))
confirmed with Control+Shift+Enter.
 
Upvote 0
Control+shift+enter, not just enter:

=AVERAGE(IF(COLUMN(A2:F2)<=SMALL(IF(ISNUMBER(A2:F2),COLUMN(A2:F2)),MIN(3,COUNT(A2:F2))),IF(ISNUMBER(A2:F2),A2:F2)))
 
Upvote 0
Thank Eric. I've tried the formula suggested above but it doesn't seem to work. It returns the answer 3.5 when the answer should be 2.

I think the formula is calculating the average of all cells where a value is entered (i.e. 5+0+1+8) then dividing it by the number of cells with values (i.e. 4) to give the answer 3.5.

However I only want the formula to calculate the average for the three most recent values (i.e. 5+0+1 divided by 3) to return an answer of 2.

Any idea how I can do this?

Thanks.
 
Upvote 0

Forum statistics

Threads
1,214,786
Messages
6,121,553
Members
449,038
Latest member
Guest1337

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