+ Reply to Thread
Results 1 to 8 of 8

Using a formula to calculate Last 10 Games and Win/Loss Streak

  1. #1
    Registered User
    Join Date
    07-06-2011
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2007
    Posts
    4

    Using a formula to calculate Last 10 Games and Win/Loss Streak

    I've created a workbook for the 2011–12 NHL season so I can calculate standings based on what would happen if the NHL were to change their current standings format of Win-Regulation Loss-Overtime/Shootout Loss to a basic Win-Loss format, where standings are based on Win Percentage instead of Points.

    To do this, I've used a workbook of the 2011–12 schedule created by Dirk Hoag of On the Forecheck, where I can enter the results of each game in the sheet labeled "Results", and all the team's stats will be calculated automatically using formulas and reflected in 3 standings tables, on the sheets "League", "Conference" and "Division" (for the entire league standings, the standings of the two conferences, and the standings of the six divisions, respectively). I found formulas to calculate each team's stats, i.e. Wins, Losses, Home/Away Record, Goals For/Against/Difference, etc. from various places on the internet, especially here.

    Attached is the workbook, but here's a sample formula, used to calculate the Home Wins for the team whose name appears in B2 on the sheet labeled "League":

    =SUMPRODUCT((Results!G$2:G$1231=B2)*(Results!D$2:D$1231<=Results!E$2:E$1231)*(Results!C$2:C$1231<=Results!F$2:F$1231)*(Results!E$2:E$1231<>""))

    (Since the season hasn't started, I've entered some hypothetical results to test the formulas.)

    The only thing I can't figure out how to calculate are the columns labeled "L10" and "Streak". "L10" means the team's Win-Loss record in their last 10 games, and "Streak" is the team's current Win-Loss streak. Can anyone figure out formulas I can use to calculate these? I only need the formula to be used on the sheet named "League", I can transpose info to use them on the other two sheets. Also, I'd prefer a formula, as I'm not familiar with using VBA. Thanks in advance.
    Attached Files Attached Files

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Using a formula to calculate Last 10 Games and Win/Loss Streak

    The below is put together with a view to amending as little as possible regards your "source" data sheet - as such things are quite complex.

    First, create some named ranges... with League!A2 the active cell add the following Defined Names:

    Please Login or Register  to view this content.
    With the above inserted we can then add some formulae to calculate streak and Last "n" performance.

    First we can add a couple of helper cells to assist our calcs...

    Please Login or Register  to view this content.
    In simplistic terms:

    - Col Q tells us the last result for the given team be it a Win (1) or a Loss (-1)
    - Col R establishes from which row of results data set we should begin to look for results (ie discounting those prior to last "n" fixtures)


    Then...

    Please Login or Register  to view this content.
    NOTES:

    -- Should you modify O1 from L10 to L5 for ex. the calculations will adapt automatically.
    -- Streak does not rely on L"n" - it will use all fixtures to determine the streak.

    I have attached a working sample of the above.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    07-06-2011
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Using a formula to calculate Last 10 Games and Win/Loss Streak

    First, thank you so much for your help!

    I have some input on your sample. The Streak column seems to work in the opposite way it should. It looks like the formula in the Streak column treats the most recent games as the ones at the top, whereas the most recent games are actually the ones at the bottom. Is this something you can change?

    Also, I have inserted two new columns in the Results sheet (see attachment). "V W/L" reflects whether the visiting team won or lost, and "H W/L" reflects whether the home team won or lost. "W" or "L" is displayed in each cell depending on the results of the formula in the cell. I realize this messes up the formulas that you inserted in your attachment, but I was hoping that these new columns would maybe help to calculate L10 and Streak better, by just looking at the "W" or "L" that each team gets in each game and adding up consecutive instances of "W" or "L", maybe making for less complex formulas. Let me know if this helps or not. If not, those two new columns can be deleted.

    Next, I feel I should have clarified the scoring format in the "Results" sheet, as it's not one normally used in hockey. Hopefully this will also help in making better formulas if you know how I determine the winner! Looking at the "Results" sheet, the score is laid out in columns D through G. Column E is the score for the visiting team, and column F is the score for the home team. These reflect the score in both regulation and overtime. If one is greater than the other, then the greater value determines the winning team. If the values are equal, that means the game went to a shootout. Column D shows how many goals the visiting team scored in the shootout, and column G shows the home team's score in the shootout. If the scores in columns E and F are equal (the regulation and overtime score), then the shootout score (columns D and G) determine the winner, with the assumption that either D or G will be greater, since it's the tiebreaker.

    Following is the formula I use to determine whether the result for the home team is a "W" or "L" (as listed in cell I2 in the "Results" sheet):

    Please Login or Register  to view this content.
    A similar formula is used to determine the result for the visitor:

    Please Login or Register  to view this content.
    These formulas check to make sure both the E cell and F cell aren't empty before comparing the game's score, and if the E and F values equal each other, checks to make sure the D and G cells (shootout score) aren't empty before comparing the shootout scores to see which is bigger.

    This brings me to another point: Is it possible to redo the formulas for L10 and Streak so that, if all the scores in the "Results" page are empty, it displays a dash? This is just a little nitpicky thing, but I'd like to have the cells in the standings tables not contain error messages if no games have been played.

    I hope this isn't far too much work! Thanks again for your help!
    Attached Files Attached Files
    Last edited by thelogician; 07-10-2011 at 09:14 PM. Reason: Did not copy down H W/L and V W/L formulas, so had to re-upload workbook.

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Using a formula to calculate Last 10 Games and Win/Loss Streak

    I am at work presently so can't really review your most recent attachment, however, regards my earlier sample and your points...

    Quote Originally Posted by thelogician
    The Streak column seems to work in the opposite way it should. It looks like the formula in the Streak column treats the most recent games as the ones at the top, whereas the most recent games are actually the ones at the bottom. Is this something you can change?
    The previous frequency calculation was indeed incorrect. The below should work.

    Please Login or Register  to view this content.
    Quote Originally Posted by thelogician
    I feel I should have clarified the scoring format in the "Results" sheet, as it's not one normally used in hockey. Hopefully this will also help in making better formulas if you know how I determine the winner! Looking at the "Results" sheet, the score is laid out in columns D through G. Column E is the score for the visiting team, and column F is the score for the home team. These reflect the score in both regulation and overtime. If one is greater than the other, then the greater value determines the winning team. If the values are equal, that means the game went to a shootout. Column D shows how many goals the visiting team scored in the shootout, and column G shows the home team's score in the shootout. If the scores in columns E and F are equal (the regulation and overtime score), then the shootout score (columns D and G) determine the winner, with the assumption that either D or G will be greater, since it's teh tiebreaker.
    The above is to all intents and purposes irrelevant from a formula perspective.

    Put simply the winner is the greater of D + E versus F + G
    Given D & G will only be used if E & F are the same adding D & G to E & F respectively does not matter - applying this logic consistently actually simplifies rather than complicates matters.


    If you are happy to use "helpers" on Results tab then you should... whether or not the formulae you've added are best suited to the task I can't comment as I can't review your file presently. As and when I have the time I will report back, assuming others do not intervene in the interim of course.

  5. #5
    Valued Forum Contributor
    Join Date
    10-13-2010
    Location
    Sunderland, England
    MS-Off Ver
    Excel 2007 (Home) / 2003 (Work)
    Posts
    740

    Re: Using a formula to calculate Last 10 Games and Win/Loss Streak

    Given that I wouldn't know where to start with amending DonKeyOte's array formulae, I have produced an alternative instead, involving helper colums on the Results tab.

    It probably won't work as quickly given the use of INDIRECT, but it works in the interim until Mr Ote comes up with a more elegant solution.

    EDIT: I'm getting a database error when I upload for some reason, and it seems like the Don has already beaten me to it anyway!
    Last edited by brokenbiscuits; 07-11-2011 at 05:17 AM.

  6. #6
    Registered User
    Join Date
    07-06-2011
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Using a formula to calculate Last 10 Games and Win/Loss Streak

    broken,

    Do you still get an error in uploading? I'd love to see your alternative.

  7. #7
    Registered User
    Join Date
    08-03-2013
    Location
    Haaltert
    MS-Off Ver
    Excel 2013
    Posts
    2

    Re: Using a formula to calculate Last 10 Games and Win/Loss Streak

    and how would the formula looks like if you won't be counting OT's and you would want to calculate Last 5 games (for example). I would like to know how to calculate last 5 games Win, Draw, Lose, Goals For and Goals Against

  8. #8
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Using a formula to calculate Last 10 Games and Win/Loss Streak

    Hello gerben69 & Welcome to the Forum,

    Administrative Note:
    • Somebody would be happy to help with your query, but first, before we can proceed…
    • Please see Forum Rule #2...Do not post a question in the thread of another member -- start your own thread..
    • If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.
    • Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    HTH
    Regards, Jeff

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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