+ Reply to Thread
Results 1 to 26 of 26

Rolling calculations based on interval

  1. #1
    Forum Contributor
    Join Date
    09-13-2016
    Location
    Kenya
    MS-Off Ver
    Excel 2010
    Posts
    317

    Rolling calculations based on interval

    In the workbook attached, the last 5 matches played by Watford are shaded in red. Out of these 5, three were home matches while two were away matches.
    Out of these 5 matches, what would be the formula that would calculate matches won at home, matches won away, matches drawn away, matches drawn away, matches lost at home, matches lost away, total goals scored at home, total goals scored away, total goals conceded at home and total goals conceded away. The formula should self-update when more data is added to the workbook.

    Expected results for Watford are below the calculations table.
    Note: The interval (i.e. last 5 matches) should be tied to cell M1 so that it can be changed at any time without altering the formula. Only the last 5 matches are to be considered (shaded in red)

    Attachment 513054
    OnditiGK

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Rolling calculations based on interval

    Hi Onditi,

    As you have found, the format of your data with Home and Away teams is a problem. A team could be in the Home column or the Away column, making it very hard to do formulas on them.

    I'd suggest you look at the attached file where I've entered your data in a different way on Sheet2. Entering results in this manner will allow you to do Pivot Tables and get the results you want. I need to add a column of goals scored against and then work from there. See what I've done to see if you can get your answers from this new format of the information.

    Home and Away better Table.xlsx
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Contributor
    Join Date
    09-13-2016
    Location
    Kenya
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Rolling calculations based on interval

    Thanks Marvin, for your response. But there is nothing wrong with the format as other calculations are working fine. I believe it is just a matter of referencing. I believe with the count function this can be achieved by counting the number of wins, draws and losses. For the goals scored the sumif function applies but I don't know how to restrict my formula to only the latest five matches.

  4. #4
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Rolling calculations based on interval

    M6=sumproduct(($c$6:$c$385=$l6)*(row($c$6:$c$385)>=max(row($c$6),large(index((($c$6:$c$385=$l6)+($f$6:$f$385=$l6))*row($f$6:$f$385),0),$m$1)))*($g$6:$g$385="w"))
    n6=sumproduct(($f$6:$f$385=$l6)*(row($c$6:$c$385)>=max(row($c$6),large(index((($c$6:$c$385=$l6)+($f$6:$f$385=$l6))*row($f$6:$f$385),0),$m$1)))*($h$6:$h$385="w"))
    o6=sumproduct(($c$6:$c$385=$l6)*(row($c$6:$c$385)>=max(row($c$6),large(index((($c$6:$c$385=$l6)+($f$6:$f$385=$l6))*row($f$6:$f$385),0),$m$1)))*($g$6:$g$385="d"))
    p6=sumproduct(($f$6:$f$385=$l6)*(row($c$6:$c$385)>=max(row($c$6),large(index((($c$6:$c$385=$l6)+($f$6:$f$385=$l6))*row($f$6:$f$385),0),$m$1)))*($h$6:$h$385="d"))
    q6=sumproduct(($c$6:$c$385=$l6)*(row($c$6:$c$385)>=max(row($c$6),large(index((($c$6:$c$385=$l6)+($f$6:$f$385=$l6))*row($f$6:$f$385),0),$m$1)))*($g$6:$g$385="l"))
    r6=sumproduct(($f$6:$f$385=$l6)*(row($c$6:$c$385)>=max(row($c$6),large(index((($c$6:$c$385=$l6)+($f$6:$f$385=$l6))*row($f$6:$f$385),0),$m$1)))*($h$6:$h$385="l"))
    s6=sumproduct(($c$6:$c$385=$l6)*(row($c$6:$c$385)>=max(row($c$6),large(index((($c$6:$c$385=$l6)+($f$6:$f$385=$l6))*row($f$6:$f$385),0),$m$1)))*($d$6:$d$385))
    t6=sumproduct(($f$6:$f$385=$l6)*(row($c$6:$c$385)>=max(row($c$6),large(index((($c$6:$c$385=$l6)+($f$6:$f$385=$l6))*row($f$6:$f$385),0),$m$1)))*($e$6:$e$385))
    try this and copy towards down
    see the attached file
    Attached Files Attached Files
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  5. #5
    Forum Contributor
    Join Date
    09-13-2016
    Location
    Kenya
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Rolling calculations based on interval

    Thank you nflsales. Your formula worked magic.

  6. #6
    Forum Contributor
    Join Date
    09-13-2016
    Location
    Kenya
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Rolling calculations based on interval

    In the workbook attached, matches played by Watford both at home and away.

    In the last 5 matches played at home, Watford has won 2, drawn in 1, lost 2, scored 8 goals and conceded 8 goals.

    In the last 5 away matches, Watford has won 2, drawn in 2, lost 1, scored 6 goals and conceded 6 goals.

    In the last 5 Home/Away matches, won 2, drawn in 2, scored 4 goals and conceded 4 goals.

    What would be the formula that would calculate these values? The formula should self-update when more results are captured.

    Notes:
    i. For home calculations, consider only home matches (5 home matches)
    ii. For away calculations, consider only away matches (5 away matches)
    iii. For Home/Away (H/A), consider only the latest 5 home and away matches by date.
    iv. The interval should be tied to cell M1

    Attachment 513100

  7. #7
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,417

    Re: Rolling calculations based on interval

    You said that Nflsales' formula "worked magic", but I don't see it in your new workbook. However the request is ostensibly the same - please explain (a) in what way the formula you previously accepted as working now isn't functioning correctly and in what way and (b) what you have tried to change in it to make it work.
    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.

  8. #8
    Forum Contributor
    Join Date
    09-13-2016
    Location
    Kenya
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Rolling calculations based on interval

    AliGW, the workbook and the question I posted earlier was wrong. The initial and current questions are different. I realized the mistake while testing the formulas.

  9. #9
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,417

    Re: Rolling calculations based on interval

    Yes, but it is still the same issue. Keep the discussion here, please, and explain in what way this query differes slightly from your original.

  10. #10
    Forum Contributor
    Join Date
    09-13-2016
    Location
    Kenya
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Rolling calculations based on interval

    The range of data to be taken into consideration differs depending on the fields of calculations. It is explained before the two attachments?

  11. #11
    Forum Contributor
    Join Date
    09-13-2016
    Location
    Kenya
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Rolling calculations based on interval

    Kindly check the info related to each attachment for the difference.

  12. #12
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,417

    Re: Rolling calculations based on interval

    I am sorry, but I can see no real difference between your latest sheet and the one you posted before. If all that you are wanting changed is the range of data, then surely you can adapt the formulae you were given before to take the new range into consideration?

  13. #13
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,337

    Re: Rolling calculations based on interval

    Try .. based on Siva's formulae in Post #4

    For WATFORD:

    M17

    =SUMPRODUCT(($C$6:$C$385=$L17)*(ROW($C$6:$C$385)>=MAX(ROW($C$6),LARGE(INDEX((($C$6:$C$385=$L17))*ROW($C$6:$C$385),0),$M$1)))*($G$6:$G$385="w"))

    N17

    =SUMPRODUCT(($F$6:$F$385=$L17)*(ROW($F$6:$F$385)>=MAX(ROW($C$6),LARGE(INDEX((($F$6:$F$385=$L17))*ROW($F$6:$F$385),0),$M$1)))*($H$6:$H$385="w"))

    O17

    =SUMPRODUCT(($C$6:$C$385=$L17)*(ROW($C$6:$C$385)>=MAX(ROW($C$6),LARGE(INDEX((($C$6:$C$385=$L17)+($F$6:$F$385=$L17))*ROW($F$6:$F$385),0),$M$1)))*(($G$6:$G$385="w")+($H$6:$H$385="w")))

    For Away and D just change "W" to "A" and "L"

    V17

    =SUMPRODUCT(($C$6:$C$385=$L17)*(ROW($C$6:$C$385)>=MAX(ROW($C$6),LARGE(INDEX((($C$6:$C$385=$L17))*ROW($F$6:$F$385),0),$M$1)))*($D$6:$D$385))

    W17

    =SUMPRODUCT(($F$6:$F$385=$L17)*(ROW($C$6:$C$385)>=MAX(ROW($C$6),LARGE(INDEX((($F$6:$F$385=$L17))*ROW($F$6:$F$385),0),$M$1)))*($E$6:$E$385))

    in X17


    =SUMPRODUCT(($C$6:$C$385=$L17)*(ROW($C$6:$C$385)>=MAX(ROW($C$6),LARGE(INDEX((($C$6:$C$385=$L17)+($F$6:$F$385=$L17))*ROW($F$6:$F$385),0),$M$1)))*($D$6:$D$385))+SUMPRODUCT(($F$6:$F$385=$L17)*(ROW($C$6:$C$385)>=MAX(ROW($C$6),LARGE(INDEX((($C$6:$C$385=$L17)+($F$6:$F$385=$L17))*ROW($F$6:$F$385),0),$M$1)))*($E$6:$E$385))

    for Y, Z,AA reverse the D and E ranges

    My results are in Row 31
    Attached Files Attached Files
    Last edited by JohnTopley; 04-17-2017 at 12:20 PM.

  14. #14
    Forum Contributor
    Join Date
    09-13-2016
    Location
    Kenya
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Rolling calculations based on interval

    Thank you John, this is the solution I needed. God Bless.

  15. #15
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,337

    Re: Rolling calculations based on interval

    Thank you for the feedback and rep. Credit to Siva for the original formulae.

  16. #16
    Forum Contributor
    Join Date
    09-13-2016
    Location
    Kenya
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Rolling calculations based on interval

    HERE IT IS:

    When home matches won, drawn and lost are summed up, the total should be 5 unless the team in question has played less than 5 matches on home ground e.g. Liverpool which has played 4 matches at home. When away matches won, drawn and lost are also summed up, the total should also be five unless the team has played less than 5 matches away from home e.g. Burnley.

    But when Home/Away matches won, drawn or lost are summed up, the total should strictly be 5 because we are considering the latest five matches. In this case, the venue is not important since we are considering the 5 matches not by venue of play. So the total for H/A under games played in the calculations table should be 5.

    Note: Matches to consider for H/A computations for Watford are highlighted.

    Attachment 513255

  17. #17
    Forum Contributor
    Join Date
    09-13-2016
    Location
    Kenya
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Rolling calculations based on interval

    I was thinking that maybe the date column should also be considered?

  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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,417

    Re: Rolling calculations based on interval

    As you seem to want further help, I've marked the thread as unsolved.

  19. #19
    Forum Contributor
    Join Date
    09-13-2016
    Location
    Kenya
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Rolling calculations based on interval

    Thank you AliGW.

  20. #20
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,337

    Re: Rolling calculations based on interval

    ...then add all dates to your file (whether any solution requires them or not).

    Checking your files, the results for Watford are the same with only the added columns showing that we consider five games which is value in M1
    Last edited by JohnTopley; 04-18-2017 at 05:12 AM.

  21. #21
    Forum Contributor
    Join Date
    09-13-2016
    Location
    Kenya
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Rolling calculations based on interval

    John, sorry to trouble you. would you be kind to help feed the formula in the file using another approach apart from the one already used? I am still struggling to learn the SUMPRODUCT functions and Moving means and other Rolling/Moving calculations.

    "When home matches won, drawn and lost are summed up, the total should be 5 unless the team in question has played less than 5 matches on home ground e.g. Liverpool which has played 4 matches at home. When away matches won, drawn and lost are also summed up, the total should also be five unless the team has played less than 5 matches away from home e.g. Burnley.

    But when Home/Away matches won, drawn or lost are summed up, the total should strictly be 5 because we are considering the latest five matches. In this case, the venue is not important since we are considering the 5 matches not by venue of play. So the total for H/A under games played in the calculations table should be 5."

    Note: Matches to consider for H/A computations for Watford are highlighted.

    Attachment 513266


    Note: Kindly refer to my last attachment. We used Watford as a sample but the formula should apply to all teams. The totals in column "O" under H/A should be five:

  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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,417

    Re: Rolling calculations based on interval

    Onditi - your data is incomplete. You need to include ALL DATES, as requested by John above.

  23. #23
    Forum Contributor
    Join Date
    09-13-2016
    Location
    Kenya
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Rolling calculations based on interval

    Here is the file with all dates included. John, sorry I had missed the date part in your last post. AliGW, thanks for the correction.

    Attachment 513270

  24. #24
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,337

    Re: Rolling calculations based on interval

    For H/A

    =SUMPRODUCT(($C$6:$C$385=$L6)*(ROW($C$6:$C$385)>=MAX(ROW($C$6),LARGE(INDEX((($C$6:$C$385=$L6)+($F$6:$F$385=$L6))*ROW($F$6:$F$385),0),$P$1)))*(($G$6:$G$385="w")))+SUMPRODUCT(($F$6:$F$385=$L6)*(ROW($C$6:$C$385)>=MAX(ROW($C$6),LARGE(INDEX((($C$6:$C$385=$L6)+($F$6:$F$385=$L6))*ROW($F$6:$F$385),0),$P$1)))*(($H$6:$H$385="w")))

    Change W to D and L
    Attached Files Attached Files
    Last edited by JohnTopley; 04-18-2017 at 06:39 AM.

  25. #25
    Forum Contributor
    Join Date
    09-13-2016
    Location
    Kenya
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Rolling calculations based on interval

    Thank you John.

  26. #26
    Registered User
    Join Date
    04-17-2017
    Location
    Kansas
    MS-Off Ver
    2010
    Posts
    18

    Re: Rolling calculations based on interval

    Just wondering if the OP is interested in this workbook I threw together.

    It's not complete, properly formatted, divisions/conferences aren't set up properly yet, and so on.

    If you are interested, let me know and I can do all the formatting according to how your league is set up.

    Is this the league you're following?
    http://www.bbc.com/sport/football/premier-league/table
    Attached Files Attached Files
    Last edited by lastdroidkiller; 04-19-2017 at 10:13 AM.

+ 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. Filter criteria based on time interval
    By Anuru in forum Excel Formulas & Functions
    Replies: 22
    Last Post: 09-03-2016, 12:14 PM
  2. Replies: 1
    Last Post: 04-29-2014, 04:42 AM
  3. [SOLVED] How to make an interval and search for values within that interval?
    By gamoerma in forum Excel General
    Replies: 12
    Last Post: 10-13-2013, 10:33 AM
  4. Rolling 12 week calculations?!?!?
    By ShellyB37 in forum Excel General
    Replies: 5
    Last Post: 11-10-2011, 07:34 AM
  5. [SOLVED] Calculate a number based on an interval
    By Vitalie Ciobanu in forum Excel General
    Replies: 4
    Last Post: 03-19-2006, 04:00 PM
  6. Calculations with date time interval
    By Todd F. in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-22-2005, 03:05 PM
  7. time interval calculations in excel
    By Krishna in forum Excel General
    Replies: 6
    Last Post: 04-08-2005, 10:06 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