+ Reply to Thread
Results 1 to 15 of 15

Creating a formula to return the average of the top 5 scores for a certain player in table

  1. #1
    Registered User
    Join Date
    05-12-2023
    Location
    New Jersey
    MS-Off Ver
    Office 365 64 bit
    Posts
    6

    Question Creating a formula to return the average of the top 5 scores for a certain player in table

    Hello everyone. Hoping that someone can help end my frustrations with writing a formula.

    Basically, I have a list of various players who have a score for multiple weeks that they played cornhole. I am trying to create a formula that will allow me to find to the top 5 scores of a certain player and calculate the average of those top 5 scores. The table contains many different players so I need to formula to match the name that I designate and then perform the task of finding the top 5 scores for that person and calculating the average. My thought was to have a table with all the player names and then the formula in the cell to the left that uses player name to calculate the average of the top 5 scores by locating them in the list of all players data. I included that table with the names at the bottom of the data set. I was trying to use AVERAGEIF with the LARGE function where the condition would be to find the player name but i can't get it to work. Any help would be greatly appreciated! I have attached the file to this post.
    Attached Files Attached Files

  2. #2
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2505
    Posts
    13,762

    Re: Creating a formula to return the average of the top 5 scores for a certain player in t

    Edited: Needed to fine tune the last formula.

    Hello Drewtime. Welcome to the forum.

    Try in E2 this formula to get the unique players names.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Then in D2 this and copied down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Yields this:


    D
    E
    2
    5.116
    James B
    3
    6.3
    Chris W
    4
    6.782
    Al H
    5
    6.022
    Justin W
    6
    6.184
    Joe R
    7
    5.954
    Daniel F
    8
    6.622
    Josh D
    9
    4.378
    Kyle N
    10
    Frank A
    11
    6.194
    Wags
    12
    5.934
    Andrew S
    Last edited by FlameRetired; 05-12-2023 at 05:08 PM.
    Dave

  3. #3
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2505
    Posts
    13,762

    Re: Creating a formula to return the average of the top 5 scores for a certain player in t

    If you've a mind to use the newer Office 365 functions.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2506 Win 11
    Posts
    24,800

    Re: Creating a formula to return the average of the top 5 scores for a certain player in t

    An alternative with Power Query and a bit convoluted
    Please Login or Register  to view this content.
    Excel 2016 (Windows) 64 bit
    E
    F
    86
    Display Name Average
    87
    Al H
    6.782
    88
    Andrew S
    5.934
    89
    Bill B
    5.57
    90
    Chris W
    6.3
    91
    Daniel F
    5.954
    92
    Frank A
    5.225
    93
    James B
    5.116
    94
    Joe R
    6.184
    95
    Josh D
    6.622
    96
    Justin W
    6.022
    97
    Kyle N
    4.378
    98
    Wags
    6.194
    Sheet: ScoreMagic
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  5. #5
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,957

    Re: Creating a formula to return the average of the top 5 scores for a certain player in t

    I took a pivot table approach.

    I converted the data into a table. Since tables know how big they are you can continue to add data and you do not have to make any adjustments other than to refresh the pivot table.

    I added some helper columns to the data. Column D computes the rank of the score and column E determines if the score is within the top 5 for the person.

    The pivot table in columns A & B is the "answer." The pivot table in columns E&F are there for QA to confirm that the average of the top 5 is what the first pivot table shows. You don't need this table
    Attached Files Attached Files
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  6. #6
    Registered User
    Join Date
    05-12-2023
    Location
    New Jersey
    MS-Off Ver
    Office 365 64 bit
    Posts
    6

    Re: Creating a formula to return the average of the top 5 scores for a certain player in t

    Hi everyone, thanks for the warm welcome!

    I just want to say you all all rock!! Thanks for the options! Judging by the answers I was nowhere close to something that would have worked haha.

    I'm gong to take a look at each to see what makes the most sense. At first glance, I like Dflac's pivot approach since this will easily give me the ability to add scores and use as a template for future seasons with little modification.

    I can't thank you all enough for the help! I will mark as solved.

  7. #7
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2506 Win 11
    Posts
    24,800

    Re: Creating a formula to return the average of the top 5 scores for a certain player in t

    FYI:

    With Power Query, if you make changes to the source table and then select Refresh All on the Data Tab, your output is automatically updated. No need to make any changes.

    Thanks for the feedback and marking the thread solved.

  8. #8
    Registered User
    Join Date
    05-12-2023
    Location
    New Jersey
    MS-Off Ver
    Office 365 64 bit
    Posts
    6
    No thank you guys. Any of these solutions will save me a TON of headaches and manual efforts. I was able to get the answers but it would have taken manual updating of lists per player using AVERAGE & LARGE nested formula every week and that plain stinks.

    If I remember correctly power query is just an add-on you have to enable right?

    My other question was let's say I want to share this file with someone else to update in my absence. Will they need to know how to use power query and have the add-in enabled in order to have the data update? Trying to make this as easy as possible to manage should I be out one week and need someone to step in and manage the updates.
    Last edited by AliGW; 08-15-2023 at 02:54 AM. Reason: Please do NOT quote unnecessarily!

  9. #9
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2506 Win 11
    Posts
    24,800

    Re: Creating a formula to return the average of the top 5 scores for a certain player in t

    Not true. In your version it is built in and called Get and Transpose Data. So long as they are running a version with Power Query, all they need to do is update the source file which also contains the query and click on refresh

    Power Query is a free AddIn for Excel 2010 and 2013, and is built-in functionality from Excel 2016 onwards (where it is referred to as "Get & Transform Data").

    It is a powerful yet simple way of getting, changing and using data from a broad variety of sources, creating steps which may be easily repeated and refreshed. I strongly recommend learning how to use Power Query - it's among the most powerful functionalities of Excel.

    - Follow this link to learn how to install Power Query in Excel 2010 / 2013.

    - Follow this link for an introduction to Power Query functionality.

    - Follow this link for a video which demonstrates how to use Power Query code provided.
    Last edited by alansidman; 05-13-2023 at 07:46 PM.

  10. #10
    Registered User
    Join Date
    05-12-2023
    Location
    New Jersey
    MS-Off Ver
    Office 365 64 bit
    Posts
    6

    Re: Creating a formula to return the average of the top 5 scores for a certain player in t

    Hey everyone, I actually needed to work through another week of the season before I realized something else I need the formula to take into account. Part of the season format is a player MUST play in at least 5 of the 10 weeks of the season to be qualified for the finale which would result in calculating their stats. Is there a way to exclude stats of players who do NOT meet the minimum of 5 weeks from being calculated? For example, in the attached file, "Bill" and "Frank" only have 4 scores based on the data tab which make them ineligible to be counted. Is there way to quality they need to have at least 5 scores to calculate the average?

  11. #11
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2505
    Posts
    13,762

    Re: Creating a formula to return the average of the top 5 scores for a certain player in t

    To list those qualifying players (using the source data from the first upload)
    Formula: copy to clipboard
    Please Login or Register  to view this content.



    E
    F
    86
    Name
    Top 5 Avg PPR
    87
    Justin W
    6.022
    88
    Joe R
    6.184
    89
    Josh D
    6.622
    90
    Andrew S
    5.934
    91
    Daniel F
    5.954
    92
    Chris W
    6.3
    93
    James B
    5.116
    94
    Al H
    6.782
    95
    Kyle N
    4.378
    96
    Wags
    6.194

  12. #12
    Registered User
    Join Date
    05-12-2023
    Location
    New Jersey
    MS-Off Ver
    Office 365 64 bit
    Posts
    6

    Re: Creating a formula to return the average of the top 5 scores for a certain player in t

    Does this formula replace the one in your original post or should i make a separate table to show the qualifiers after we did the pivot table to show the average of the best 5 weeks?
    Last edited by AliGW; 08-15-2023 at 02:53 AM. Reason: Please do NOT quote unnecessarily!

  13. #13
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Creating a formula to return the average of the top 5 scores for a certain player in t

    Or do the whole lot in one calculation. No copy/pasting. Paste this into a single cell (make sure the surrounding area is empty)

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  14. #14
    Registered User
    Join Date
    05-12-2023
    Location
    New Jersey
    MS-Off Ver
    Office 365 64 bit
    Posts
    6

    Re: Creating a formula to return the average of the top 5 scores for a certain player in t

    Hi Glenn,

    THanks so much for this. I was super excited to try this out but ran into problems. I downloaded this file and was adding some additional scores just to play around to see if the formula you created will work. As soon as i changed the data i got the "#NAME?" error and the message said unsupported function related to "xlfn". I copied the formula out of the file when i open it and its as follows.

    =LET(A,SORT(UNIQUE(Table1[Player Name]),1),B,_xlfn.BYROW(A,_xlfn.LAMBDA(_xlpm.x,IFERROR(AVERAGE(_xlfn.EXPAND(_xlfn.TAKE(SORT(FILTER(Table1[PPR Score],Table1[Player Name]=_xlpm.x),,-1),5),5,,NA())),"Insufficient data"))),_xlfn.VSTACK(_xlfn.HSTACK("Player Name","Average PPR Score"),_xlfn.HSTACK(A,B)))

    I noticed both excel put in "_xlpm.x" and "_xlfn." in multiple spots so i tried to remove them and the formula still didn't work. The file opens with the correct results, but it seems whenever i try to change any of the data the formula breaks and i cannot get it to work except to close without saving changes and reopen the file you attached.

    I then tried to just copy and paste the formula you supplied above but that returned an error saying something needs to be corrected in the formula syntax.

    Any ideas?
    Last edited by AliGW; 08-15-2023 at 02:52 AM. Reason: Please do NOT quote unnecessarily!

  15. #15
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Creating a formula to return the average of the top 5 scores for a certain player in t

    What Excel VERSION are you using? I t will work on O365, with any version >= 2202, which was introduced in March 2022. Is your Excekl up-to-date? Check your version and, check for updates and report back EXACTLY what your excel product is...
    Attached Images Attached Images

+ 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: 11
    Last Post: 02-03-2022, 09:49 AM
  2. Replies: 0
    Last Post: 04-20-2020, 06:51 PM
  3. Replies: 6
    Last Post: 12-06-2017, 04:40 PM
  4. Replies: 5
    Last Post: 12-31-2016, 09:12 PM
  5. Replies: 8
    Last Post: 12-20-2014, 04:37 PM
  6. [SOLVED] Top scores w/ corresponding player, also with a tie
    By madman1734 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-15-2013, 11:40 AM
  7. finding player and avg top 3 scores
    By xpostie in forum Excel General
    Replies: 6
    Last Post: 06-08-2012, 02:59 AM

Tags for this Thread

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