How Can I Average Values based Top 5 Values in another column?

btlizard

New Member
Joined
May 17, 2018
Messages
2
I have been trying to figure this out for a few days and haven't been able to find anything online with this exact situation.

I have a large set of data (~5000) with names of individuals, dates of completion, and scores assigned. I have figured out without too much difficulty how to average all of the scores for a given individual and non-blank scores and dates.

What I need to do now is to average the five most recent scores for each individual. I need to be able to find the five latest dates and average the corresponding scores, all without having to sort or extract anything, since data is constantly being added or modified.

I thought I came up with a decent solution for this, but the problem I am having is that any method that tries to find the five largest (most recent) dates and then find the corresponding score seems to want to find the first instance of that date and report the score. This is a problem for duplicate dates.

Here is the formula I have right now, but I did some test runs and I know that I am getting the wrong average of the five most recent scores for several individuals:

{=IFERROR(IF(E3>0,IF(E3<=5,F3,AVERAGE(IF((--(DESIGNER=A3))*(--(DATE>37000))*(--(SCORE<>""))*((--(DATE=LARGE(IF((--(DESIGNER= A3))*(--(DATE>37000))*(--(SCORE<>""))>0,DATE), {1,2,3,4,5}))))>0,SCORE))),"--"),"--")}

To explain a bit what I have here:
  • I have several named ranges for my data set.
  • The names are in column A.
  • Column E counts how many non-blank scores there are total for each individual.
  • Column F is the overall average for all scores.
  • Since the formula is interested in only the latest 5 scores, anything 5 or less will be the same as the overall average.
  • The reason for DATE>37000 check is ignore any dummy dates.

I would greatly appreciate any help. Also, I want to avoid VBA since this is for another end user and would like to avoid that.
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
A...EFGHI
1...
2Designer...# ScoresOverall
Avg
Last 5
Avg
Expected(delta)
3Name 1...691.1%90.9%91.2%+0.31%
4Name 2...2392.0%88.2%88.2%
5Name 3...688.6%87.2%87.2%
6Name 4...581.2%81.2%81.2%
7Name 5...5299.4%99.7%99.7%
8Name 6...1194.8%96.4%96.3%-0.15%
9Name 7...4593.2%98.6%98.1%-0.56%
10Name 8...687.7%87.4%87.4%
11Name 9...162.7%62.73%62.73%
12Name 10...167.5%67.5%67.5%

<tbody>
</tbody>

Does this help? First 10 rows of my table. As you can see, some averages match while others do not.

Here is the raw data for those that do not:

Name 1
43241 43209 43222 43237 43237 43229
0.9721 0.9063 0.8953 0.8324 0.97 0.8902

Name 6

43124 43124 43129 43136 43146 43165 43195 43174 43206 43222 43222
0.9582 0.8565 0.9546 0.9089 0.975 0.963 0.9492 0.9286 1 0.9858 0.95

Name 7 data is kinda long.
 
Upvote 0
Not sure this is what I wanted...

The following formula averages last 5 figures for a given name. If this is similar to what you intend, you can maybe adapt it to your data.

Control+shift+enter, not just enter:

=AVERAGE(IF(ROW(Figures)>=LARGE(IF(Names="jon",IF(ISNUMBER(Figures),ROW(Figures))),MIN(3,COUNTIFS(Names,"jon"))),IF(Names="jon",IF(ISNUMBER(Figures),Figures))))

Hope this helps.
 
Upvote 0

Forum statistics

Threads
1,217,360
Messages
6,136,102
Members
449,991
Latest member
IslandofBDA

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