+ Reply to Thread
Results 1 to 4 of 4

Formula to count last 18 instances of occurrence (from a specific date) to perform a SUMIF

  1. #1
    Registered User
    Join Date
    03-06-2015
    Location
    London
    MS-Off Ver
    Mac Office
    Posts
    45

    Formula to count last 18 instances of occurrence (from a specific date) to perform a SUMIF

    Hi,

    I have historical football results from the last 15 years as per attachment. What I would like to do is take a specific row and have a formula that looks back at only the last 19 home games for a team so I can calculate how many goals have been scored in that game.

    On attached, column A has date, C has the home team, D has the away team and I has the total goals scored in the game. So for example on row 4443 there is the fixture Liverpool vs. Arsenal so in column Y I'd like to be able to have a formula that looks back at only the last 19 home games that Liverpool have played before the date of this match (as per column A - 03/03/2012) and then adds up how many goals (column I) have been scored in those 19 games.

    In column Z I'd also then like to be able to look at a similar thing but the last 19 away games that Liverpool (the home team in this match) have played before 03/03/2012 and do the same formula for total goals in those last 19 when Liverpool playing away. I would then copy these fomulas all the way down from row 3 to the end of the data so I have a continual rolling record for each upcoming game.

    I am not too bad with excel and understand a large range of the formulas and logic but I'm afraid this is beyond me and would massively appreciate any help.

    Thanks!
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    03-06-2015
    Location
    London
    MS-Off Ver
    Mac Office
    Posts
    45
    Any ideas? Completely stuck! Driving me crazy.

    Quote Originally Posted by CRMORE View Post
    Hi,

    I have historical football results from the last 15 years as per attachment. What I would like to do is take a specific row and have a formula that looks back at only the last 19 home games for a team so I can calculate how many goals have been scored in that game.

    On attached, column A has date, C has the home team, D has the away team and I has the total goals scored in the game. So for example on row 4443 there is the fixture Liverpool vs. Arsenal so in column Y I'd like to be able to have a formula that looks back at only the last 19 home games that Liverpool have played before the date of this match (as per column A - 03/03/2012) and then adds up how many goals (column I) have been scored in those 19 games.

    In column Z I'd also then like to be able to look at a similar thing but the last 19 away games that Liverpool (the home team in this match) have played before 03/03/2012 and do the same formula for total goals in those last 19 when Liverpool playing away. I would then copy these fomulas all the way down from row 3 to the end of the data so I have a continual rolling record for each upcoming game.

    I am not too bad with excel and understand a large range of the formulas and logic but I'm afraid this is beyond me and would massively appreciate any help.

    Thanks!

  3. #3
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Formula to count last 18 instances of occurrence (from a specific date) to perform a S

    Okay, my formulas are pretty convoluted but they are not Arrayed.
    First I made two key columns Y for Home and Z for away
    Y3 =C3&"_"&COUNTIF($C$3:$C3, C3)
    Z3=D3&"_"&COUNTIF($D$3:$D3, D3)

    Column AA gives sum of goals from last 19 games (if there are 19 games) of the home team of that row. Col AB (not sure I got this right but would require minor changes) = sum of goals from last 19 games of the away team of that row.

    AA3 copied down

    =IF(COUNTIF($C$3:$C3,C3)<19,SUM(INDEX(($C$3:$C3=C3)*($G$3:$G3),)), SUM( INDEX(((INDEX($C$3:C3, MATCH(C3&"_"&COUNTIF($C$3:$C3, C3)-18, $Y$3:$Y3,0)):$C3=C3) *(INDEX($G$3:G3, MATCH(C3&"_"&COUNTIF($C$3:$C3, C3)-18, $Y$3:$Y3,0)):$G3)),)))

    AB3 copied down
    =IF(COUNTIF($D$3:$D3,D3)<19,SUM(INDEX(($D$3:$D3=D3)*($H$3:$H3),)), SUM( INDEX(((INDEX($D$3:D3, MATCH(D3&"_"&COUNTIF($D$3:$D3, D3)-18, $Z$3:$Z3,0)):$D3=D3) *(INDEX(H$3:$H3, MATCH(D3&"_"&COUNTIF($D$3:$D3, D3)-18, $Z$3:$Z3,0)):$H3)),)))
    Attached Files Attached Files
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  4. #4
    Forum Contributor
    Join Date
    07-10-2012
    Location
    Bangladesh
    MS-Off Ver
    Excel 2007
    Posts
    129

    Re: Formula to count last 18 instances of occurrence (from a specific date) to perform a S

    column Y sum of goales when played as home

    and goals computed in column AA when team played as away team
    Attached Files Attached Files

+ 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. VBA code to count the occurrence in a single date and the range of date
    By Sushil.thakur in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-28-2014, 02:28 AM
  2. Replies: 1
    Last Post: 02-05-2013, 09:14 AM
  3. Count Occurrence of date (6th April) between two dates...
    By noonoogizmo in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-01-2012, 06:21 AM
  4. Replies: 6
    Last Post: 06-20-2012, 07:23 PM
  5. Count the Occurrence Based on a Date
    By ChrisRocks in forum Excel General
    Replies: 2
    Last Post: 08-16-2011, 11:54 AM
  6. Count Month Occurrence in range of date
    By Bob@Sun in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-18-2010, 05:20 AM

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