1. #1
    brettd
    brettd's Avatar Become A Pro!
    Join Date: 01-25-10
    Posts: 229
    Betpoints: 3869

    Questions relating to using excel in modelling

    Hi guys,
    Just wondering why there's no big arse thread related to excel queries. I'm no programming expert, so I'm counting on excel to get me through making my first model. I'm guessing a lot of others are in the same boat.

    Here's to kick it off:

    I've got "HomeTeam" and "AwayTeam" columns in column C and D respectively. I want to extract score totals in the "HomeTotal" or "AwayTotal" in column N or Q.

    Essentially what I want to do in plain English is this:

    1. Check "HomeTeam" column cells for "Team A".
    2. If "Team A" is in cell, extract score from column N (the "HomeTotal" column)
    3. Scan through the entire column for "Team A" instances and list contiguously (no gaps; I don't want to drag down 500 rows to find the instances).

    I guess I would then rinse and repeat with "Team A" but for the away values also.

    How do I do this? I've just paid and gone through Wayne Winston's (the author of Mathletics) 20 hour excel course at HBS online, but doing this for real is a quantum leap from the examples I was learning on.

    Is this some kind of VLOOKUP task (made more complicated by the fact that the relevant columns for an array are non-contiguous), or an INDEX and MATCH task? I've fiddled around and I just can't figure it out.

  2. #2
    brettd
    brettd's Avatar Become A Pro!
    Join Date: 01-25-10
    Posts: 229
    Betpoints: 3869

    One other thing, I thought INDEX and MATCH would work here, but as I understand it, this would only find the first instance of Team A before stopping.

    Or am I wrong here?

  3. #3
    brettd
    brettd's Avatar Become A Pro!
    Join Date: 01-25-10
    Posts: 229
    Betpoints: 3869

    My overall objective is to recreate Justin7's first few modelling rules on pages 104-105 of his "Conquering Risk" book with my own dataset using excel. I'm not asking for any of the other stuff he did later in the chapter.

    If anyone can come up with a small demo of how someone can implement these rules using excel and only a small demo dataset; I would be greatly appreciative (and I think heaps of others would too). I could then deconstruct how it was made and draw inspiration from there.

  4. #4
    lovesbaseball1
    lovesbaseball1's Avatar Become A Pro!
    Join Date: 12-07-10
    Posts: 18
    Betpoints: 246

    I'd create a column that produces a 1 or a 0 if home team is in column a, something like :
    =if(iserr(find(c1, a1, 1)), 0, 1)

    then sort the list, using the 1 or the 0 in the new column.

    you could record a macro to do the sorting automatically.

  5. #5
    mrtomk
    mrtomk's Avatar Become A Pro!
    Join Date: 02-24-11
    Posts: 105
    Betpoints: 771

    Hi,

    First ever SBR post so hope its of some help. I haven't read the book you referenced, but if I understand you correctly you want to show a list of occurrences that Team A have played at home/away, and the points they scored on each occasion?

    If so, see attached link. Cell T3 has a drop down list of the various teams (Teams A, B & C), coming from column A. Select the team from the list and it should show you the points they scored in each of their Home games, and Away games. Note that this doesn't pick up the opposing team's scores as I assumed from your post this wasn't needed, instead Game No.1 shows Team A's first Home game score in column V, and first Away game score in column X.

    I created columns C & D, which pick out each time the selected team plays at Home (C) and Away (D). The vlookup in the table runs from these and picks up the first instance of the number. Hide these if they get in the way.

    Hope that makes some sense. Let me know if there are any questions. There is most likely a easier macro way of doing this, but Im not great with them...
    Attached Files
    Nomination(s):
    This post was nominated 1 time . To view the nominated thread please click here. People who nominated: brettd

  6. #6
    mrtomk
    mrtomk's Avatar Become A Pro!
    Join Date: 02-24-11
    Posts: 105
    Betpoints: 771

    PS Adjust the vlookup to include the whole column if this is a list you are permanently adding to. i.e. in my example, in column V, change $C$2:$R$22 to just $C:$R, in column X change from $D$2:$R$22, to $D:$R.

    Also, copy the formulae in columns C & D down for your whole list of scores.

    Regards

  7. #7
    brettd
    brettd's Avatar Become A Pro!
    Join Date: 01-25-10
    Posts: 229
    Betpoints: 3869

    Mate that was pure gold.

    I've played around with the sheet and it's extracting all the scores. One final thing, how do I edit the formula to sort into chronological order? Let's say column G and H had "Year" and "Round" information that would enable us to chronologically sort the info.

    So the concept of the output would look something like this:

    Game No, Home / Away?, Year, Round, Score

    1 , Home , 2006, 1 , 40

    Cheers

  8. #8
    brettd
    brettd's Avatar Become A Pro!
    Join Date: 01-25-10
    Posts: 229
    Betpoints: 3869

    Not to worry, have just figured it out. I added in new columns, copied and pasted the formula, and changed the column index number within the formula. Worked a treat.

    Thanks heaps!

  9. #9
    subs
    subs's Avatar Become A Pro!
    Join Date: 04-30-10
    Posts: 1,412
    Betpoints: 969

    mrtomk - welcome - can u post every day?

  10. #10
    jane2geo
    jane2geo's Avatar Become A Pro!
    Join Date: 04-28-10
    Posts: 93
    Betpoints: 3112

    Wow, I was going to suggest something simple like this. Place this formula in the cell you wish the accumulated TeamA totals to appear. =SUMIF(C2:C999,"TeamA",N2:N999)+ SUMIF(D2999,"TeamA",Q2:Q999)

  11. #11
    jennahazeplays
    jennahazeplays's Avatar Become A Pro!
    Join Date: 03-15-10
    Posts: 474

    i think youre right but not sure

  12. #12
    mrtomk
    mrtomk's Avatar Become A Pro!
    Join Date: 02-24-11
    Posts: 105
    Betpoints: 771

    Yep, my initial thought was to go with a sumif, but I think he wanted a list of every individual score in a list, as oppose to a sum of all the scores, which is why I went the long way around.

  13. #13
    mrtomk
    mrtomk's Avatar Become A Pro!
    Join Date: 02-24-11
    Posts: 105
    Betpoints: 771

    No worries, brettd, glad I could help...

  14. #14
    Ralphie88
    Ralphie88's Avatar Become A Pro!
    Join Date: 08-05-10
    Posts: 8

    I have some experience using Excel, but I am nowhere near as proficient as mrtomk, and I have absolutely no experience creating or using models, but like brettd I would like to learn. So I hope my questions are not too moronic. First of all, if I am using Excel to create my database/model, what are the most important Excel functions I should know/learn? Secondly, I am kind of having a difficult time grasping the model concept. What exactly does one want to include in their model? From everything I have read in "The Think Tank" and from various books, am I correct in assuming that I want to try and use as many stats as possible that will help me determine a score or total and than based on the outcome that my model produced I want to compare that to the opening/closing lines to see how effective my model is?

    Any help would be appreciated. Thank you.

  15. #15
    subs
    subs's Avatar Become A Pro!
    Join Date: 04-30-10
    Posts: 1,412
    Betpoints: 969

    i a rookie at this really, but there's no need to start from scratch...

    look at kenpom and sabermetrics. try some out ---> produce own lines ---> realize that the books r better than u ---> get better ---> realize that books r still better than u ---> review options ---> get better etc etc

    good luck

  16. #16
    brettd
    brettd's Avatar Become A Pro!
    Join Date: 01-25-10
    Posts: 229
    Betpoints: 3869

    Ralphie, I was in the same boat.

    Go through the online spreadsheet modelling course by Wayne L Winston available at HBS online, it's a good primer for learning some very useful functions (Winston is also an avid sport handicapper as well). Get Justin's Conquering Risk book, and attempt to start recreating models from his book using excel.

    That's where I'm at now.

  17. #17
    brettd
    brettd's Avatar Become A Pro!
    Join Date: 01-25-10
    Posts: 229
    Betpoints: 3869

    I'm now trying to get a "Days since last game" variable to my excel spreadsheet data for the home and away teams of each recorded match.

    How can I tell excel to check for an entry of 'Team A' in the HomeTeam column; then to find the last previous entry of 'Team A' higher up in the list (going back in the past), and then comparing these two dates?

    My columns are like this:


    HomeTeam AwayTeam Location Date

    Team A Team B Ground X 25-Mar-06


    mrtomk? anyone else got an idea? Thanks in advance.

  18. #18
    mrtomk
    mrtomk's Avatar Become A Pro!
    Join Date: 02-24-11
    Posts: 105
    Betpoints: 771

    Hello All,

    Afraid I'm behind you guys when it comes to actually developing models for stats and lines, I've just been learning the basics from this forum. So I dont know what to recommend in terms of specific functions. Only reason I know any Excel is because Ive had to use it in every job Ive had. With that in mind, there will likely be cleverer ways to solve your problems that my solutions.

    With that disclaimer, one way I can see of solving your problem, brettd, is with vlookups against columns C&D once again. In the attached sheet, column AC looks up the date for the relevant home game number, then looks up and subtracts the date of the preceding home game number. Because Excel stores dates as numbers, it will leave you with the difference between the two dates.

    The if(iserr( stuff is just to prevent #N/A popping up when there wasn't a previous home game, or a game number found. The important part is =VLOOKUP($X2,$C:$L,10,0)-VLOOKUP($X1,$C:$L,10,0), and would work equally well on its own.

    Hope that helps...
    Attached Files

  19. #19
    jane2geo
    jane2geo's Avatar Become A Pro!
    Join Date: 04-28-10
    Posts: 93
    Betpoints: 3112

    Mr Tom where were you when I was building my spreadsheets, Bravo.

  20. #20
    mrtomk
    mrtomk's Avatar Become A Pro!
    Join Date: 02-24-11
    Posts: 105
    Betpoints: 771

    On review, it occurred to me you might have wanted days since last game, instead of, or as well as, last home/away game, so I've reviewed with AC, AD and AE calculating the days since the last type of game. Besides, the sheet in my last post was slightly confusing to read. I think this one makes more sense by putting in a total games played column and working off that.

    If you need to get back to having just home scores, or away scores, just use the simple filter for NonBlanks on Home/Away Scores in the side table.

    It actually occurred to me just now that you probably could have achieved most of what you wanted just by applying the filter for the team you wanted to your main sheet in the first place, which would've saved a lot of formula writing. Good thing I enjoy messing around in Excel.

    Anyways, any other problems, let me know...
    Attached Files

  21. #21
    Ralphie88
    Ralphie88's Avatar Become A Pro!
    Join Date: 08-05-10
    Posts: 8

    Quote Originally Posted by brettd View Post
    Ralphie, I was in the same boat.

    Go through the online spreadsheet modelling course by Wayne L Winston available at HBS online, it's a good primer for learning some very useful functions (Winston is also an avid sport handicapper as well). Get Justin's Conquering Risk book, and attempt to start recreating models from his book using excel.

    That's where I'm at now.
    Thanks brettd. Would you recommend reading the book first (Mathletics) or did you learn more from the online course?

  22. #22
    brettd
    brettd's Avatar Become A Pro!
    Join Date: 01-25-10
    Posts: 229
    Betpoints: 3869

    Ralphie, I also read Mathletics in addition to Conquering Risk before before I started the excel course. I suggest you do so in the same way.

    There was a heap of spreadsheets that you can download to accompany your reading of Matheltics; you will find it easier to interpret/deconstruct these spreadsheets with the excel knowledge you will learn in the course.

    Hey mrTomk, I'll take a look at your new spreadsheet solution now. Many thanks!!!

  23. #23
    brettd
    brettd's Avatar Become A Pro!
    Join Date: 01-25-10
    Posts: 229
    Betpoints: 3869

    Hey mrtomk,
    I've fiddled around with it by inputting my own data into the cells. As you can see, i'm getting some zeros for the "days since last game" column. I'm not sure why this is. Any idea why this is happening?

    Thanks in advance.
    Attached Files

  24. #24
    mrtomk
    mrtomk's Avatar Become A Pro!
    Join Date: 02-24-11
    Posts: 105
    Betpoints: 771

    Hey brett,
    I dont have a legit version of Excel on this pc so I cant play with your spreadsheet, just look at it. But it seems the problem is in the formulae in columns B, C, D. For example, the formula in cell B4 needs to be looking across to cells E4 and F4, not down to E5 and F5. Essentially, GamesPlayed is saying does the game in this row include the team selected in T1, if so, add 1 to the Games Played total from the cell above (B3+1), if not give me the old total (B3). So B4 should read:
    =if(or($T$1=E4,$T$1=F4),B3+1,B3)

    Play with that and let me know if it works, if not I'll have a closer look...

  25. #25
    mrtomk
    mrtomk's Avatar Become A Pro!
    Join Date: 02-24-11
    Posts: 105
    Betpoints: 771

    PS Change the cells to look at the same row for columns C & D too, as yo did in B.

  26. #26
    mrtomk
    mrtomk's Avatar Become A Pro!
    Join Date: 02-24-11
    Posts: 105
    Betpoints: 771

    Should work now. See attached...
    Attached Files

  27. #27
    brettd
    brettd's Avatar Become A Pro!
    Join Date: 01-25-10
    Posts: 229
    Betpoints: 3869

    Hey mrtomk,
    Again awesome spreadsheet. Is it possible to split the 'Days Since Last Game' column into separate 'Home Days Since Last Game' and 'Away Days Since Last Game'?

    I've just spent the last 90 minutes getting separate Home and Away days since last game going for each match entry. Even though i'm now 'done' doing this, I'm pretty sure I've managed to stuff something up in the heap of filters, sorting and copy and pasting I was doing. My results are probably no good anyway.

    Mrtomk (or anyone else for that matter), is there any way we can extract both the Home and Away 'Days Since Last Game' figure for each match entry?

  28. #28
    mrtomk
    mrtomk's Avatar Become A Pro!
    Join Date: 02-24-11
    Posts: 105
    Betpoints: 771

    Hey brettd, I'm confused. Does this differ in some way from Days Since Last Home Game and Days Since Last Away Game in columns AC & AD? What do you mean by a Home/Away day?

  29. #29
    brettd
    brettd's Avatar Become A Pro!
    Join Date: 01-25-10
    Posts: 229
    Betpoints: 3869

    Quote Originally Posted by mrtomk View Post
    Hey brettd, I'm confused. Does this differ in some way from Days Since Last Home Game and Days Since Last Away Game in columns AC & AD? What do you mean by a Home/Away day?
    I think I could best explain this with an example. Let's pick East Fremantle vs East Perth on 08-Apr-06. I would like to know how many days it's been since East Fremantle played last, and the amount of days it's been since East Perth played last. Then I would like the same info for every match entry.

    Can this be done using some sort of vlookup, or does this get into the realm of VBA for excel?

  30. #30
    mrtomk
    mrtomk's Avatar Become A Pro!
    Join Date: 02-24-11
    Posts: 105
    Betpoints: 771

    Hello again brettd,

    Like all of my entries, I begin with the disclaimer that there may well be a nicer way of doing this with VBA, but my knowledge there is very limited, so I couldnt tell you either way. Maybe some one else reading could help there?

    Attached is my non-VBA solution. I can't take full credit as I had to google a way to lookup the last occurrence of a value in a range, but it works nicely. Cells in columns C & D look up the latest date in P on which the home/away team played from all those games above the current row, and subtract that value from the date of the game in question.

    All the best
    Attached Files

  31. #31
    brettd
    brettd's Avatar Become A Pro!
    Join Date: 01-25-10
    Posts: 229
    Betpoints: 3869

    Cheers mrtomk,

    Once again you've managed to help me out! The solution worked a treat.

  32. #32
    mrtomk
    mrtomk's Avatar Become A Pro!
    Join Date: 02-24-11
    Posts: 105
    Betpoints: 771

    No worries. Happy to chip in what knowledge I have. Don't hesitate if any new problems crop up... BOL

  33. #33
    threeg5
    All In A Days Work
    threeg5's Avatar Become A Pro!
    Join Date: 07-18-09
    Posts: 488
    Betpoints: 321

    Quote Originally Posted by subs View Post
    i a rookie at this really, but there's no need to start from scratch...

    look at kenpom and sabermetrics. try some out ---> produce own lines ---> realize that the books r better than u ---> get better ---> realize that books r still better than u ---> review options ---> get better etc etc

    good luck

    Why not continue this journey and then join the darkside!!
    Go work for a book as a bookies statitioneer hell after all if you can't beat'em join right?


    3g5

  34. #34
    andrewharry
    andrewharry's Avatar Become A Pro!
    Join Date: 03-08-11
    Posts: 2

    Its good to see such a response, I am having problems related to importing data from database located on server into my options excel file. How to go about it this process has to be carried out on a regular basis and I am not that good in server and client side technologies.

  35. #35
    jane2geo
    jane2geo's Avatar Become A Pro!
    Join Date: 04-28-10
    Posts: 93
    Betpoints: 3112

    More details would help……….!

12 Last
Top