+ Reply to Thread
Results 1 to 7 of 7

Matching on multiple variables, like SQL's IN Function

  1. #1
    Registered User
    Join Date
    12-08-2017
    Location
    United States
    MS-Off Ver
    2016
    Posts
    53

    Matching on multiple variables, like SQL's IN Function

    Is there a way to match on multiple values within the MATCH function? This is my current formula to determine (and later, pick) a passing grade in a class (A to D-), with DF2 the ID:

    =IF(ISNUMBER(MATCH(1, (DF2='GRADES'!$B$2:$B$16056)*(('GRADES'!$K$2:$K$16056="A")+('GRADES'!$K$2:$K$16056="A-")+('GRADES'!$K$2:$K$16056="B+")+('GRADES'!$K$2:$K$16056="B")+('GRADES'!$K$2:$K$16056="B-")+('GRADES'!$K$2:$K$16056="C+")+('GRADES'!$K$2:$K$16056="C")+('GRADES'!$K$2:$K$16056="C-")+('GRADES'!$K$2:$K$16056="D+")+('GRADES'!$K$2:$K$16056="D")+('GRADES'!$K$2:$K$16056="D-")),0)), "Yes", "No")

    I tried to shorten it this way but it did not work:

    =IF(ISNUMBER(MATCH(1, (DF2='GRADES'!$B$2:$B$16056)*('GRADES'!$K$2:$K$16056 = {"A","A-","B+","B","B-","C+","C","C-","D+","D","D-"}),0)), "Yes", "No")

    Is there any way to shorten this formula in this manner? The only thing I could think of is to give each letter a number value, with D- at 1 up to A at 11, with F as 0:
    =IF(ISNUMBER(MATCH(1, (DF2='GRADES'!$B$2:$B$16056)*('GRADES'!$K$2:$K$16056 >0),0)), "Yes", "No")

    Thank you.

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,942

    Re: Matching on multiple variables, like SQL's IN Function

    Why don't you just return the grade:

    =VLOOKUP(DF2,'GRADES'!$B:$K,10,False)

    And wouldn't any failing grade just be F?

    =IF(VLOOKUP(DF2,'GRADES'!$B:$K,10,False)="F","No","Yes")

    Otherwise, show a short example of your data, and describe what you would want returned from your example.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    12-08-2017
    Location
    United States
    MS-Off Ver
    2016
    Posts
    53

    Re: Matching on multiple variables, like SQL's IN Function

    Thank you, but I need to have a dummy variable both for if the ID has a passing grade and another if it is a B or better, both Yes/No. I cannot just return the grade because a person may have taken the class multiple times with different grades. I am interested in if he or she ever passed or ever got a B or better.

    Just curious, so there is no way to shorten the MATCH formula that way?

    Thank you again.

  4. #4
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Matching on multiple variables, like SQL's IN Function

    May be...
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Confirmed as array (CTRL + SHIFT + ENTER)
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  5. #5
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,942

    Re: Matching on multiple variables, like SQL's IN Function

    This will return the number of A and A- grades for the ID in DF2: if can easily be extended to count B+ B B- etc...

    =SUMPRODUCT((GRADES!$B$2:$B$16000&GRADES!$K$2:$K$16000=DF2&"A")+(GRADES!$B$2:$B$16000&GRADES!$K$2:$K$16000=DF2&"A-"))

  6. #6
    Registered User
    Join Date
    12-08-2017
    Location
    United States
    MS-Off Ver
    2016
    Posts
    53

    Re: Matching on multiple variables, like SQL's IN Function

    Quote Originally Posted by CK76 View Post
    May be...
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Confirmed as array (CTRL + SHIFT + ENTER)
    Thank you. This is much more efficient!

  7. #7
    Registered User
    Join Date
    12-08-2017
    Location
    United States
    MS-Off Ver
    2016
    Posts
    53

    Re: Matching on multiple variables, like SQL's IN Function

    Quote Originally Posted by Bernie Deitrick View Post
    This will return the number of A and A- grades for the ID in DF2: if can easily be extended to count B+ B B- etc...

    =SUMPRODUCT((GRADES!$B$2:$B$16000&GRADES!$K$2:$K$16000=DF2&"A")+(GRADES!$B$2:$B$16000&GRADES!$K$2:$K$16000=DF2&"A-"))
    Thank you. Do you know why this would not work within the Match function?

+ 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 function with multiple variables
    By se7en in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 07-13-2013, 01:45 PM
  2. [SOLVED] Populating a drop down list dependent on multiple matching variables
    By Sardaukar in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-28-2013, 02:48 AM
  3. [SOLVED] Sum Function based on multiple variables
    By Mr. H2 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 02-27-2013, 02:42 PM
  4. [SOLVED] Multiple Sheet Search - Matching Variables
    By plasma33 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-16-2012, 06:02 AM
  5. [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
  6. Function for Multiple Variables
    By leynadsvision in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-18-2008, 11:54 AM
  7. if function multiple variables
    By cin in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-08-2005, 05:05 PM

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