Offset and averageif question.

pjmoorhouse71

New Member
Joined
Sep 28, 2017
Messages
1
Good afternoon,

Hope someone can assist - I have the following formula which works perfectly to average the last 5 results of data in column D. Column D is a productivity rate and just a regular number

=AVERAGE(OFFSET(Stats!D3,COUNTA(Stats!D3:D100)-5,0,5.1))

However, column C has one of 4 entries - let's say either a,b,c or d (the name of a machine) - I want to adapt the above forumla so that it calculates the average of the last 5 numbers in column D based on what is column C. So I can see the average of the last 5 entries in column D where column C has "a" in it or "b" etc.

Hope this is clear and someone can help.

Thanks.
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Can you add an additional column in E? If so I would arrange the data like this:
CDEFGH
3A1005
4C25
5A54
6C34
7A63Machine Name =A
8A102Average =5.6
9A21
10A50
11C10

<tbody>
</tbody>


E3=COUNTIF(C:C,$H$7)-COUNTIF($C$3:C3,$H$7)
H7User input for the name of the machine
H8=AVERAGEIFS(D3:D11,C3:C11,H7,E3:E11,"<"&5)

<tbody>
</tbody>
Hope this helps!
-Andrew
 
Upvote 0
Welcome to the board.

Another possibility:

=AVERAGE(IF((C3:C100="a")*(ROW(C3:C100)>=LARGE(IF(C3:C100="a",ROW(C3:C100)),5)),D3:D100))

confirmed with Control+Shift+Enter.
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,595
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