+ Reply to Thread
Results 1 to 25 of 25

Looking up results from a list with two variables

  1. #1
    Registered User
    Join Date
    06-24-2010
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    32

    Looking up results from a list with two variables

    I have a database of football results. In column A I have the Home Team. In Column B I have the Away Team. In Column C is Home Goals, Column D is Away Goals, Column E is Result (Home (H), Away (A) or Draw (D), Column F is the date.

    I want to be able to put into a different sheet a fixture, Cell A1 - Home Team XXXX vs Cell B1 - Away Team YYYY, and I want it to pull the most recent 10 games between those 2 teams from the database. If there are not 10, then just all the results, if there are over 10, the most recent.

  2. #2
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Looking up results from a list with two variables

    Perhaps using this ARRAY formula in a cell in Sheet 2 and copying down and across?

    =INDEX(Sheet1!A$2:A$1000,SMALL(IF((Sheet1!$A$2:$A$1000=$A$1)*(Sheet1!$B$2:$B$1000=$B$1),ROW(Sheet1!A$2:A$1000)-1),ROW(Sheet1!A1)))
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  3. #3
    Registered User
    Join Date
    06-24-2010
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Looking up results from a list with two variables

    Here is an example workbook. On Fixtures sheet, in A2 I will put a home team, in B2 Away team, and want it to populate cells C2-L2, most recent first pulling from Column E on results sheet.
    Attached Files Attached Files

  4. #4
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Looking up results from a list with two variables

    Try

    =IFERROR(INDEX(Results!$F$2:$F$1000;SMALL(IF((Results!$A$2:$A$1000=$A$2)*(Results!$B$2:$B$1000=$B$2)*(LARGE(Results!$F$2:$F$1000;COLUMN(A1)));ROW(Results!$F$2:$F$1000)-1);COLUMN(A1)));"")
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    06-24-2010
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Looking up results from a list with two variables

    Thanks. thats almost it, but instead of pulling the date, i want to pull the info in column E, the H,A or D. Is that possible?

  6. #6
    Registered User
    Join Date
    06-24-2010
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Looking up results from a list with two variables

    Thanks. thats almost it, but instead of pulling the date, i want to pull the info in column E, the H,A or D. Is that possible?

  7. #7
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Looking up results from a list with two variables

    Just replace the INDEX part of the formula from =IFERROR(INDEX(Results!$F$2:$F$1000

    to =IFERROR(INDEX(Results!$e$2:$e$1000

  8. #8
    Registered User
    Join Date
    06-24-2010
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Looking up results from a list with two variables

    I tried that and it's just pulling through H, H, H when it should be D, D, D

  9. #9
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Looking up results from a list with two variables

    It's just because you don't follow my instrunctions(see post#2). This is an ARRAY formula. Follow the link that i provided in post#2 and read about ARRAY formulas.



    -- Array(CSE) { }, formulae are confirmed with Control+Shift+Enter.
    Not just Enter.

  10. #10
    Registered User
    Join Date
    06-24-2010
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Looking up results from a list with two variables

    I didn't see the link - have read it now, appreciate the help, thanks.

  11. #11
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Looking up results from a list with two variables

    You are welcome and thanks for the feed back.

    As that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thank you.

  12. #12
    Registered User
    Join Date
    06-24-2010
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Looking up results from a list with two variables

    Ok, so now I have a similar question. I have tried messing about with the formula but to no avail. I want to bring up the same information, but only searching the team listed in column A, whoever the opponent, and whether they are home or away. So for example

    Team listed at home week 1, away week 2, home week 3. Team name is in A3, want it to match and bring up the result for that team whether they are home or away. i guess I need to remove the reference to the team in the second column as before, but it doesn't seem to make any difference. thanks in advance.

  13. #13
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Looking up results from a list with two variables

    Hi

    I do want to continue to help you, but:

    1) Pls. This thread started 3 days ago and if you have a new question every 2 days we'll continue for many others.. So pls Collect all of your questions and make them. I'll try to answer to all of them.

    2) I am not in your mind not even in your workbook to undrestand which is your thoughts and which is(are) your new goal(s). So pls upload a sample workbook that will show the lay out of your data and your expected results.

  14. #14
    Registered User
    Join Date
    06-24-2010
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Looking up results from a list with two variables

    Fotis, thanks for your continued help. Apologies for not asking all questions together. I have collated them now with what I am trying to do, and uploaded an example workbook also.

    All I will be changing is the values in Column A and Column B, from A2:A151 and B2:B151. I would then like to pull a series of results based on the values of one or both those cells.

    Q1) Find most recent 10 results (result field is Database Column E) of team listed in column A, regardless of whether they are home or away.

    Q2) Find last 10 home results of team listed in column A.

    Q3) Find last 10 results of either combination between team listed in column A & Column B. For example xxxx vs yyyy, or yyyy vs xxxx.

    Q4) Sum of columns C&D for either combination of teams eg xxxx vs yyyy or yyyy vs xxxx

    Q5) Sum of Column C when Column A is Home team

    Q6) Find results of last 5 games for Column C, where team in A2:A151 is either home or away (similar to Q1)

    Q7) Find results of last 5 games where A2:A151 is the home team only.


    They are all my questions, I am sure they are variations of each other, I am just not sure how to reference a single team, a combination of 2 teams or the variable where an individual team is home or away.

    Again, many thanks in advance for your help.

  15. #15
    Registered User
    Join Date
    06-24-2010
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Looking up results from a list with two variables

    Here is the example sheet
    Attached Files Attached Files

  16. #16
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Looking up results from a list with two variables

    Q1

    =LARGE(IF(Results!$A$2:$B$1000=$A$2;Results!$F$2:$F$1000);ROW(A1))

    Q2

    =LARGE(IF(Results!$A$2:$A$1000=$A$2;Results!$F$2:$F$1000);ROW(A1))

    Q3---I DON'T UNDERSTAND..

    q4

    =SUMIF(Results!$A$2:$A$1000;A2;Results!$C$2:$C$1000)+SUMIF(Results!$A$2:$A$1000;A2;Results!$D$2:$D$1000)+SUMIF(Results!$B$2:$B$1000;A2;Results!$C$2:$C$1000)+SUMIF(Results!$B$2:$B$1000;A2;Results!$D$2:$D$1000)

    q5

    =SUMIF(Results!A2:A1000;A2;Results!C2:C1000)

    q6 & q7 look to me same questions as q1 & q2.
    Attached Files Attached Files

  17. #17
    Registered User
    Join Date
    06-24-2010
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Looking up results from a list with two variables

    Thank you Fotis, this is amazing, that is exactly what I was looking for.

    With regard to Q3, in the example sheet I am looking for the last 10 results of either Leierse v Haralbeke, or Haralbeke v Leierse. Effectively the result of the last 10 times they have met. I think its probably a variation of Q1 adding in the second team variable, but I am not sure.

    Thank you so much for your help, if we can get the answer to 3 then I am good to go!

  18. #18
    Registered User
    Join Date
    06-24-2010
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Looking up results from a list with two variables

    Actually Fotis, I just noticed an issue. You are pulling the dates as the results in column F of the results tab. I actually need to pull the data in column E. I will have to reference the date though to get the most recent. Sorry for the misunderstanding.

  19. #19
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Looking up results from a list with two variables

    So in this case formula for Q1 will be.

    =INDEX(Results!$E$2:$E$1000,MATCH(LARGE(IF(Results!$A$2:$B$1000=$A$2,Results!$F$2:$F$1000),ROW(A1)),Results!$F$2:$F$1000,0))

    Modify the formula for the other questions..

    -- Array(CSE) { }, formulae are confirmed with Control+Shift+Enter.
    Not just Enter.

    For q3, i'll take a look later..

  20. #20
    Registered User
    Join Date
    06-24-2010
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Looking up results from a list with two variables

    perfect, thank you!

  21. #21
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Looking up results from a list with two variables

    Taking a second look to your data and trying some formulas for q3, i see that in fact Q3 is the same result as q1 !

    See the example
    Attached Files Attached Files

  22. #22
    Registered User
    Join Date
    06-24-2010
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Looking up results from a list with two variables

    Ok, so having applied all the formulas and played around with them, I cannot get them to work and dont know why, so I am uploading the sheet exactly as it will be in my workbook, with references from which questions apply to which result set. I am looking for the result, not the date to be pulled through.

    Hopefully its just something minor I am missing, and we can get this resolved finally.

    Thank you for your continued help.
    Attached Files Attached Files

  23. #23
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Looking up results from a list with two variables

    I really want to apologize but as today is my last day in work before my summer holidays , i have no time at all to see it again(starting from the beginning).

    I hope that someone will be able to helps you OR you have to wait 10 days. Then i'll be able to take a look to this again.

  24. #24
    Registered User
    Join Date
    06-24-2010
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Looking up results from a list with two variables

    No problem, I understand. Thanks for all your help and have a great holiday.

    Anyone? Can anyone help pick up Fotis' work and help me get this finished please?

  25. #25
    Registered User
    Join Date
    06-24-2010
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Looking up results from a list with two variables

    Fotis, Any chance you could take a look at this please. thanks.

+ 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. IF statement with multiple variables and results
    By lance214 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-22-2012, 05:38 PM
  2. [SOLVED] Pulling Multiple Results by Matching one variable from List of Variables
    By caitlinkeats in forum Excel General
    Replies: 5
    Last Post: 04-09-2012, 07:24 PM
  3. Replies: 4
    Last Post: 02-27-2012, 08:39 AM
  4. Multiple variables, responses and results?
    By Vienings in forum Excel General
    Replies: 1
    Last Post: 06-24-2011, 05:40 AM
  5. How Do I Sort by Multiple Variables in Excel and Display the Results Elsewhere?
    By Astrodog in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-02-2010, 08:49 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