+ Reply to Thread
Results 1 to 43 of 43

Find a Text, average last 20,if < 20 average all available.

  1. #1
    Registered User
    Join Date
    03-08-2016
    Location
    Canada
    MS-Off Ver
    2015
    Posts
    70

    Find a Text, average last 20,if < 20 average all available.

    help.PNG


    So In box d2 I would like excel to find palmer's last 20 appearance's and average his yards in these appearances. If he is not found 20 times I would excel to average whatever is available. Thank you so much for any help
    Attached Files Attached Files
    Last edited by richhhh; 08-27-2016 at 05:32 PM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,800

    Re: Find a Text, average last 20,if < 20 average all available.

    What do you mean by last 20? Do you mean the last 20 entries in the list?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    03-08-2016
    Location
    Canada
    MS-Off Ver
    2015
    Posts
    70

    Re: Find a Text, average last 20,if < 20 average all available.

    Yes last 20 entries in the list. Sorry for any confusion. Thank you for checking in

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,800

    Re: Find a Text, average last 20,if < 20 average all available.

    Are you able to attach a sample workbook?

  5. #5
    Registered User
    Join Date
    03-08-2016
    Location
    Canada
    MS-Off Ver
    2015
    Posts
    70

    Re: Find a Text, average last 20,if < 20 average all available.

    I would have to start another thread for that lol. I originally tried that and uploaded file but When I scroll over attachment section I had no option to post. So I left to take a picture and upload that instead.

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,800

    Re: Find a Text, average last 20,if < 20 average all available.

    No, you wouldn't. You can add an attachment to any post: use the Go Advanced button and scroll down until you see Manage Attachments in blue - click it.

  7. #7
    Registered User
    Join Date
    03-08-2016
    Location
    Canada
    MS-Off Ver
    2015
    Posts
    70

    Re: Find a Text, average last 20,if < 20 average all available.

    File is attached thank you

  8. #8
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Find a Text, average last 20,if < 20 average all available.

    Try this...

    D2 = Palmer

    This array formula** entered in E2:

    =AVERAGE(IF(ROW(B2:B169)>=LARGE(IF(A2:A169=D2,ROW(A2:A169)),MIN(20,COUNTIF(A:A,D2))),IF(A2:A169=D2,B2:B169)))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  9. #9
    Registered User
    Join Date
    03-08-2016
    Location
    Canada
    MS-Off Ver
    2015
    Posts
    70

    Re: Find a Text, average last 20,if < 20 average all available.

    Thank you for your help. Altho it did produce some numbers it did not calculate correctly. Most cells had errors and the ones that received a calculation were all the same for each person which means it did not average the last 20 appearances. I will spend some time on it to see if I can figure something out. Thank you again

  10. #10
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Find a Text, average last 20,if < 20 average all available.

    Works in your posted sample file...
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    03-08-2016
    Location
    Canada
    MS-Off Ver
    2015
    Posts
    70

    Re: Find a Text, average last 20,if < 20 average all available.

    Maybe this will help someone help me. Here I managed to get averages and will sort each name and there averages all the way down. I want instead the averages for the last 20 instead of the average of everytime the name appears. Also if the name does not appear 20 times I want the average of everytime the name appeared.





    help.PNG
    Attached Files Attached Files
    Last edited by richhhh; 08-27-2016 at 07:47 PM.

  12. #12
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Find a Text, average last 20,if < 20 average all available.

    Many members are unable to see images in the *.png format due to forum compatibility issues with some browsers.

    If you need to post an image post it in the *.jpg format.

    Even better than posting images... post a SMALL sample file. That way we can test solutions directly in the file with the relevant data.

  13. #13
    Registered User
    Join Date
    03-08-2016
    Location
    Canada
    MS-Off Ver
    2015
    Posts
    70

    Re: Find a Text, average last 20,if < 20 average all available.

    Ok tony I think I see whats going on. Its likey how I am explaining. I see in your sample that it did in fact calculate kolb.

    If A2 is Palmers name then I would like E2 to be palmers average of last 20 appearance's. If he has not appeared 20 times then average of everyone he has.
    If A2 is Kolbs name then I would like E2 to be kolbs average of last 20 appearance's. If he has not appeared 20 times then average of everyone he has.
    I would like this to roll all the way down getting the name from A? and place currents averages in same section . A15/e15 etcc..
    I will upload another excel.

    Cant thank you enough for your time and apologizes if my explaining is not sufficient.

  14. #14
    Registered User
    Join Date
    03-08-2016
    Location
    Canada
    MS-Off Ver
    2015
    Posts
    70

    Re: Find a Text, average last 20,if < 20 average all available.

    I added another work book to my most recent post.

  15. #15
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Find a Text, average last 20,if < 20 average all available.

    Hi richhhh. I am pretty confident that we understand what you need very well. The problem is that you did not apply formula properly and that's why your results did not come out right.
    I will offer you another array formula so may be it work better for you.
    See image below and verify that numbers came out right.
    In my example I entered formula in cell D2 and copied down. I also have unique list of names in Column C
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    ***Array formula
    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER.
    You will know the array is active when you see curly braces { } appear around your formula.
    If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.


    v A B C D
    1 Player yards Unique Name List Average last 20 or less
    2 Palmer 235 Palmer 271.35
    3 Palmer 349 Lindley 177.25
    4 Palmer 213 Stanton 218.38
    5 Palmer 269 Hoyer 225.00
    6 Palmer 274 Skelton 235.13
    7 Palmer 310 Kolb 240.23
    8 Palmer 362 Bartel 242.00
    9 Palmer 271 Anderson 217.70
    10 Palmer 317 Hall 160.00
    11 Palmer 363 Warner 277.30
    12 Palmer 374 Leinart 220.38
    13 Palmer 275 Rattay 180.00
    14 Palmer 421
    15 Palmer 171
    16 Palmer 352
    17 Palmer 311
    Attached Files Attached Files
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  16. #16
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Find a Text, average last 20,if < 20 average all available.

    Quote Originally Posted by richhhh View Post
    I added another work book to my most recent post.
    Based on the data in the help3 file.

    Data Range
    D
    E
    1
    Player
    Average
    2
    Palmer
    271.35
    3
    Lindley
    177.25
    4
    Stanton
    218.375
    5
    Hoyer
    225
    6
    Skelton
    235.1333
    7
    Kolb
    240.2308
    8
    Bartel
    242
    9
    Anderson
    217.7
    10
    Hall
    160
    11
    Warner
    277.3
    12
    Leinart
    220.375
    13
    Rattay
    180


    This array formula** entered in e2 and copied down:

    =AVERAGE(IF(ROW(B$2:B$169)>=LARGE(IF(A$2:A$169=D2,ROW(A$2:A$169)),MIN(20,COUNTIF(A:A,D2))),IF(A$2:A$169=D2,B$2:B$169)))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

  17. #17
    Registered User
    Join Date
    03-08-2016
    Location
    Canada
    MS-Off Ver
    2015
    Posts
    70

    Re: Find a Text, average last 20,if < 20 average all available.

    You are definitely skilled in excel! But again I dont think I have clearly pointed out what I am looking for.


    I am not looking for a list of all the players and there averages. I want the players averages of there last 20 beside where there name is. For example if Palmer names goes down 10 straight I want the average of his last 20 beside it everytime( the average will change everytime) When the player the name changes it will search that players last 20 and calculate the average of his last 20 and put it beside it. (if he does not appear 20 times in the entire list it will average everything that is there)
    My very simply formula went down the list and gave a average every time each player no matter what order but it just does not give me the last 20 or the condition of if the name does not appear often.

    Much appreciated all the work you have done.

  18. #18
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,800

    Re: Find a Text, average last 20,if < 20 average all available.

    Richhhh - if you look at AlKey's last file, you will see a working formula. The formulae in column D are array formulae and have been entered using CTRL+SHIFT+ENTER (not just ENTER). If you enter them using just ENTER, they will not work correctly.

    Here's the output I think you want using AlKey's latest formula, which I have made one tweak to so that it is checking the name from column A instead of the extra column C that he had added:

    Excel 2016 (Windows) 32 bit
    A
    B
    C
    D
    1
    Player yards Average last 20. If less then 20 average all avaible
    2
    Palmer
    235
    271.35
    3
    Palmer
    349
    271.35
    4
    Palmer
    213
    271.35
    5
    Palmer
    269
    271.35
    6
    Palmer
    274
    271.35
    7
    Palmer
    310
    271.35
    8
    Palmer
    362
    271.35
    9
    Palmer
    271
    271.35
    10
    Palmer
    317
    271.35
    11
    Palmer
    363
    271.35
    12
    Palmer
    374
    271.35
    13
    Palmer
    275
    271.35
    Sheet: Sheet1

    Excel 2016 (Windows) 32 bit
    D
    2
    =AVERAGE(INDEX(B:B,N(IF(1,LARGE(INDEX((A$2:A$169=A2)*(ROW(B$2:B$169)),0),ROW(INDIRECT("1:20")))))))
    Sheet: Sheet1

    Formula confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.

  19. #19
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Find a Text, average last 20,if < 20 average all available.

    try this (See column G in attached) [array formula control + Shift + enter]

    =AVERAGE(IF(IF(A2=A2:A$169,B2:B$169)*IF(COUNTIF(INDIRECT("A"&ROW(A2)&":A"&ROW(2:$169)),A2)<=20,1)=0,FALSE,IF(A2=A2:A$169,B2:B$169)*IF(COUNTIF(INDIRECT("A"&ROW(A2)&":A"&ROW(2:$169)),A2)<=20,1)))
    Attached Files Attached Files
    Happy with my advice? Click on the * reputation button below

  20. #20
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,800

    Re: Find a Text, average last 20,if < 20 average all available.

    Ah, I think I see now - it's an incremental average.

    @Crooza - I see what you've done, but should Palmer's first average on the list not just be 235?

    @Richhh - this would be so much easier if you would give us some expected outcomes!!!

  21. #21
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082
    Quote Originally Posted by AliGW View Post
    Ah, I think I see now - it's an incremental average.

    @Crooza - I see what you've done, but should Palmer's first average on the list not just be 235?

    @Richhh - this would be so much easier if you would give us some expected outcomes!!!
    I interpreted it as the average of the most recent 20 scores. I saw this as the 20 scores below the present score.

  22. #22
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,800

    Re: Find a Text, average last 20,if < 20 average all available.

    So you are assuming that the latest score is at the top of the list? I was assuming that the latest score would be at the bottom.

    Richhhh really needs to give us some expected outcomes, as there have been several different interpretations of his requirements so far!

  23. #23
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Find a Text, average last 20,if < 20 average all available.

    Yeah I assumed working from the top being the most recent scores. This could be a totally wrong assumption. If so I'll need to rework the formula but the logic should hold true for the structure of the formula (I think)

  24. #24
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Find a Text, average last 20,if < 20 average all available.

    Are you able to sort the data so that the names are grouped together?

    If so, could you post a new file and show us what results you expect?

  25. #25
    Registered User
    Join Date
    03-08-2016
    Location
    Canada
    MS-Off Ver
    2015
    Posts
    70

    Re: Find a Text, average last 20,if < 20 average all available.

    Quote Originally Posted by Crooza View Post
    try this (See column G in attached) [array formula control + Shift + enter]

    =AVERAGE(IF(IF(A2=A2:A$169,B2:B$169)*IF(COUNTIF(INDIRECT("A"&ROW(A2)&":A"&ROW(2:$169)),A2)<=20,1)=0,FALSE,IF(A2=A2:A$169,B2:B$169)*IF(COUNTIF(INDIRECT("A"&ROW(A2)&":A"&ROW(2:$169)),A2)<=20,1)))


    This appears to be exactly what I am looking for! Thank you so much! Looks like I can easily change the average to median if I choose to as well!

    I want to thank everyone who replied.Tony I apologize if I caused any confusion. Your time was greatly appreciated.

    I am going to spend some time when I get home verifying formula and the results. I also need to modify it to do other things other then yards which have different numbers etc.... With some things I also want to change how many games it goes back etc..

    You guys are awesome !

  26. #26
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,800

    Re: Find a Text, average last 20,if < 20 average all available.

    You're welcome. In future you should ALWAYS include some expected outcomes in your sample data AND explain how you've arrived at them.

  27. #27
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Find a Text, average last 20,if < 20 average all available.

    Good deal. Thanks for the feedback!

  28. #28
    Registered User
    Join Date
    03-08-2016
    Location
    Canada
    MS-Off Ver
    2015
    Posts
    70

    Re: Find a Text, average last 20,if < 20 average all available.

    =AVERAGE(IF(IF(A2=A2:A$169,B2:B$169)*IF(COUNTIF(INDIRECT("A"&ROW(A2)&":A"&ROW(2:$169)),A2)<=20,1)=0,FALSE,IF(A2=A2:A$169,B2:B$169)*IF(COUNTIF(INDIRECT("A"&ROW(A2)&":A"&ROW(2:$169)),A2)<=20,1)))

    Ok This formula is working!! So amazing!


    I would like to ask for just a little more help.(The nerve of me)

    So the above is working but I would like to make some adjustments.. If A2 is Palmer it does search A2:A169 for the last 20 times Palmer appeared and average the numbers in the corresponding B section. So if Palmer appeared in A2,A4,A6,A7,A8,A9,A10,A11(untill it has 20) ETCC.. It would average B2,B4,B6,B7,B8,10,B11 numbers etc. But the number in B2 is not part of his last 20 as it is his current. I would like it to still search for 20 but not use B2.

    Also When the scenario arises where a player does not appear 20 times it is in fact averaging the available cells from the current cell down all the way to row169. This is great but in this scenario I actually want it to search A2:A169 and average everytime his name appeared. So if there is not a past 20 it will use past/current/future to obtain its average.

    Sample file added. Column J contains results that I would like. Thank you again guys.
    Attached Files Attached Files
    Last edited by richhhh; 08-28-2016 at 04:47 PM.

  29. #29
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Find a Text, average last 20,if < 20 average all available.

    Different approach. (using your sample file from post #11).

    In C2, filled down

    =COUNTIF(A$2:A2,A2)

    In D2, filled down

    =AVERAGEIFS($B3:$B$169,$A3:$A$169,A2,$C3:$C$169,"<="&(C2+20))

    Does that give the expected results?

  30. #30
    Registered User
    Join Date
    03-08-2016
    Location
    Canada
    MS-Off Ver
    2015
    Posts
    70

    Re: Find a Text, average last 20,if < 20 average all available.

    Quote Originally Posted by jason.b75 View Post
    Different approach. (using your sample file from post #11).

    In C2, filled down

    =COUNTIF(A$2:A2,A2)

    In D2, filled down

    =AVERAGEIFS($B3:$B$169,$A3:$A$169,A2,$C3:$C$169,"<="&(C2+20))

    Does that give the expected results?

    It is giving the expected results! Except when the player does not appear 20 times. As I want it to average all that players numbers from the start of the list a2:a169 when there is less then 20 appearance in the past (down the list)
    Last edited by richhhh; 08-28-2016 at 04:49 PM.

  31. #31
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Find a Text, average last 20,if < 20 average all available.

    So using Lindley as an example, the formula in D21 should include the figures from B20 and B21 as part of the average?

    =IF(COUNTIF($A$2:$A$169,A2)>20,AVERAGEIFS($B3:$B$169,$A3:$A$169,A2,$C3:$C$169,"<="&(C2+20)),AVERAGEIF($A$2:$A$169,A2,$B$2:$B$169))

  32. #32
    Registered User
    Join Date
    03-08-2016
    Location
    Canada
    MS-Off Ver
    2015
    Posts
    70

    Re: Find a Text, average last 20,if < 20 average all available.

    Yep absolutely. Cant thank you enough. This appears to working . I am going to put it the test.

    I believe I need to change (COUNTIF($A$2:$A$169,A2) to (COUNTIF(A2:A169,A2) as what will happen is a player like palmer who appears more then 20 but at some point will appear less then 20 in the past will not get the condition in those situations that is in place for players who do not appear 20 times. Where in the situation where he does not have 20 past results I want all of his games averaged (B2:b169) I think that makes sense. The theory being less relevant data is much better then small sampled data.

  33. #33
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Find a Text, average last 20,if < 20 average all available.

    Palmer appears 40 times in the list, if you use that method then it will average all 40 entries once it gets past the point of less than 20 remaining in the list.

    Is that what you want or do you just want to average a max of 20 appearances from the bottom up?

    Which version of excel are you using?

    If you have an office 365 subscription then some of the extra features that come with it could prove useful, but not essential.

  34. #34
    Registered User
    Join Date
    03-08-2016
    Location
    Canada
    MS-Off Ver
    2015
    Posts
    70

    Re: Find a Text, average last 20,if < 20 average all available.

    Yes the max 20 appearances from the bottom up would be the best!

    Yes I have a office 365 subscription

  35. #35
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Find a Text, average last 20,if < 20 average all available.

    Quote Originally Posted by richhhh View Post

    Ok This formula is working!! So amazing!


    I would like to ask for just a little more help.(The nerve of me)
    That's Great and happy to assist

    Quote Originally Posted by richhhh View Post
    So the above is working but I would like to make some adjustments.. If A2 is Palmer it does search A2:A169 for the last 20 times Palmer appeared and average the numbers in the corresponding B section. So if Palmer appeared in A2,A4,A6,A7,A8,A9,A10,A11(untill it has 20) ETCC.. It would average B2,B4,B6,B7,B8,10,B11 numbers etc. But the number in B2 is not part of his last 20 as it is his current. I would like it to still search for 20 but not use B2.

    Also When the scenario arises where a player does not appear 20 times it is in fact averaging the available cells from the current cell down all the way to row169. This is great but in this scenario I actually want it to search A2:A169 and average everytime his name appeared. So if there is not a past 20 it will use past/current/future to obtain its average.

    Sample file added. Column J contains results that I would like. Thank you again guys.
    I've adjusted formula to do the 20 excluding the current line BUT I looked at the bottom of the table where you run out of data (hence less than 20 entries remaining) and the average seems to be working fine in regard to only averaging the available number of entries. Can you give me line number where this isn't working the way you expect it to and let me know what your expected answer for that line number would be? thanks

    Here's the formula - again an array formula so control + shift + enter

    =AVERAGE(IF(IF(A2=A3:A$169,B3:B$169)*IF(COUNTIF(INDIRECT("A"&ROW(A3)&":A"&ROW(3:$169)),A2)<=20,1)=0,FALSE,IF(A2=A3:A$169,B3:B$169)*IF(COUNTIF(INDIRECT("A"&ROW(A3)&":A"&ROW(3:$169)),A2)<=20,1)))

  36. #36
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Find a Text, average last 20,if < 20 average all available.

    Try this one in column D

    =AVERAGEIFS($B$2:$B$169,$A$2:$A$169,A2,$C$2:$C$169,">"&MIN(C2,COUNTIF($A$2:$A$169,A2)-20),$C$2:$C$169,"<="&C2+20)

  37. #37
    Registered User
    Join Date
    03-08-2016
    Location
    Canada
    MS-Off Ver
    2015
    Posts
    70

    Re: Find a Text, average last 20,if < 20 average all available.

    Quote Originally Posted by Crooza View Post
    That's Great and happy to assist



    I've adjusted formula to do the 20 excluding the current line BUT I looked at the bottom of the table where you run out of data (hence less than 20 entries remaining) and the average seems to be working fine in regard to only averaging the available number of entries. Can you give me line number where this isn't working the way you expect it to and let me know what your expected answer for that line number would be? thanks

    Here's the formula - again an array formula so control + shift + enter

    =AVERAGE(IF(IF(A2=A3:A$169,B3:B$169)*IF(COUNTIF(INDIRECT("A"&ROW(A3)&":A"&ROW(3:$169)),A2)<=20,1)=0,FALSE,IF(A2=A3:A$169,B3:B$169)*IF(COUNTIF(INDIRECT("A"&ROW(A3)&":A"&ROW(3:$169)),A2)<=20,1)))


    That formula is something! Thank you !


    Ok so it working as I want it to for entries that appear more then 20 times and have more then 20 occurrences below.

    But row 20 (Lindley) is a example of what is not working as I would like it to. Lindley only appears 6 times. What I would like is in this scenario average all 6 of his appearance .Which would equal 178. So all six times lindley appears = 178. So 20,21,22,57,58,59 would all = 178.

    Row 51 (palmer). In this scernario altho palmer does appear more then 20 times in total in column A he only appears once below row 51 in which he scored 327 yrds and that is what is imputed in row 51. I would prefer the average of every appearance so row 51 =284.

    What would also be even better which was recently discussed above that in the Palmer case above where row 51 = 284 that the most recent 20 appearance is used instead of every appearance.(in this scenario it will average 20 starting from the bottom) using this method row 51=271.

    Thank you again!

  38. #38
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Find a Text, average last 20,if < 20 average all available.

    Quote Originally Posted by richhhh View Post


    But row 20 (Lindley) is a example of what is not working as I would like it to. Lindley only appears 6 times. What I would like is in this scenario average all 6 of his appearance .Which would equal 178. So all six times lindley appears = 178. So 20,21,22,57,58,59 would all = 178.
    OK I think I understand now. Firstly Lindley appears 8 times so I think my solution for row 20 is correct. You've missed rows 54 and 55 which adds 246 104 so average is 177.25
    For the less ones where you want it to average ALL the values if less than 20 I'll need to think about that some more and come back to you.

  39. #39
    Registered User
    Join Date
    03-08-2016
    Location
    Canada
    MS-Off Ver
    2015
    Posts
    70

    Re: Find a Text, average last 20,if < 20 average all available.

    Quote Originally Posted by jason.b75 View Post
    Try this one in column D

    =AVERAGEIFS($B$2:$B$169,$A$2:$A$169,A2,$C$2:$C$169,">"&MIN(C2,COUNTIF($A$2:$A$169,A2)-20),$C$2:$C$169,"<="&C2+20)


    Bingo! Worked as expected! Thank you Thank you.

  40. #40
    Registered User
    Join Date
    03-08-2016
    Location
    Canada
    MS-Off Ver
    2015
    Posts
    70

    Re: Find a Text, average last 20,if < 20 average all available.

    Quote Originally Posted by Crooza View Post
    OK I think I understand now. Firstly Lindley appears 8 times so I think my solution for row 20 is correct. You've missed rows 54 and 55 which adds 246 104 so average is 177.25
    For the less ones where you want it to average ALL the values if less than 20 I'll need to think about that some more and come back to you.
    Looks like Jason got me to where I need to be. Altho I would love your formula as well please dont break a sweat on it. Cant thank you enough for all your hard work.

  41. #41
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Find a Text, average last 20,if < 20 average all available.

    OK. I looked at Jason's solution and it's giving a different answer to what you expected in row 51 from your post #37.

    This will at least give you your desired output in row 51 (as well as many others but I'm still not sure I I've got all the logic right for the less than 20 occurences. I think I do but I'm getting some different answers to Jason but I'm more closely aligned with your example answers in your version 4 file

    =IF(COUNTIF(A3:$A169,A2)<=20,AVERAGEIF($A$2:$A$169,A2,$B$2:$B$169),AVERAGE(IF(IF(A2=A3:A$169,B3:B$169)*IF(COUNTIF(INDIRECT("A"&ROW(A3)&":A"&ROW(3:$169)),A2)<=20,1)=0,FALSE,IF(A2=A3:A$169,B3:B$169)*IF(COUNTIF(INDIRECT("A"&ROW(A3)&":A"&ROW(3:$169)),A2)<=20,1))))

    As Jason has showed it is much easier with a helper column in C but if you want a single solution this might be as close as you can get in a single formula

  42. #42
    Registered User
    Join Date
    03-08-2016
    Location
    Canada
    MS-Off Ver
    2015
    Posts
    70

    Re: Find a Text, average last 20,if < 20 average all available.

    Crooza your formula is giving exactly what I asked for. Yours and jason's are identical except the cells where a player appears more then 20 times in column A but down the list far enough that there is less then 20 below and this is only different because Jason mentioned a idea that I liked and he modified it to count most recent 20 when this occurs( bottom up)
    Most definitely easier to give a helper column and not to mention it is more user friendly so a not very experienced user can make sense out it like myself. Yours on the other hand although complicated for me to read does the job and since I have to do similar things with many names in different columns/different numbers may be the route for me. I will have to play around with both. Now that I have them I am planing to learn from them.To be honest I am shocked I got exactly what I was after and giving two approaches is just surreal. No idea the fat kids ways to achieve my results you guys saved me from. Thank You Guys!

  43. #43
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082
    Great. Glad it worked. Have fun deciphering the two formulas. You'll learn heaps working these few examples out

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 15
    Last Post: 10-20-2015, 11:19 AM
  2. Find the average when the cell contains text
    By castlesmith in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 11-23-2014, 06:36 AM
  3. [SOLVED] Find Average, Return Column Header of Number Closest To Average
    By djmyers in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 07-07-2013, 04:19 PM
  4. Index/Match to find Starting Point of Average, Ending Point of Average Variable
    By tgentry in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-09-2012, 01:04 AM
  5. The rank of average ranks excluding empty cells but including their average.
    By Terminal45 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-21-2012, 03:44 AM
  6. [SOLVED] UDF code to find specific text in cell comments, then average cell values
    By bruch04 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-05-2005, 06:10 PM
  7. [SOLVED] how does one convert text to a formula "average(A:A)" to =average(
    By phshirk in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-13-2005, 09:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1