+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Registered User
    Join Date
    12-09-2009
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    55

    Match function nested in an If statement

    I have multiple sheets within one Excel file. Each sheet is structured the same way. Column B lists Client's last names, which differ from sheet to sheet, though some clients may be repeated in several tabs. I have a column K which displays either the number 1 or 0. This is consistent between sheets.

    I have created a formula that will look at the last name in a specific cell in column B of sheet 2 (FY 07) and search sheet 1 (FY 06) column B for the same last name.

    =IF(MATCH($B5,'FY 06'!$B$5:$B$24,0),1,0)

    If the same last name exists and if column K of sheet 2 and sheet 1 display a "1", I want it to place a 0 in the formula cell.

    So, if there is a client that is in both sheets and has a "1" in both columns K of each sheet, I want the formula to let me know.

    I'm having difficulty wording this, so I hope it makes sense. Any help would be appreciated. I've attached a sample excel file for further clarification.
    Attached Files Attached Files

  2. #2
    Forum Moderator ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    Victoria, Canada
    MS-Off Ver
    2003 & 2010
    Posts
    1,797

    Re: Match function nested in an If statement

    Hi dforte,

    Try this:

    Code:
    =IF(AND(NOT(ISNA(MATCH(B5,'FY 06'!$B$5:$B$24,0))),K5=1,'FY 06'!K5=1),0,1)
    Cheers,
    Last edited by ConneXionLost; 12-09-2009 at 02:05 AM.
    Docendo discimus.

    Please consider:
    • Thanking those who helped you. Click the reputation icon in the contributor's post and add Reputation.
    • Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

  3. #3
    Registered User
    Join Date
    12-09-2009
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    55

    Re: Match function nested in an If statement

    Thank you so much, ConneXionLost! This works well when both sheets' column K has a 1. However, when there is a "0" in column K of the second sheet, I still want the formula to return 0, but it returns 1...

    Column K measures growth (represented by 1). If growth was achieved by this individual in a previous sheet, I want it to return 0, which it does. However, if a new individual does not experience growth ('0'), the formula returns '1'. Any further suggestions?

  4. #4
    Forum Moderator ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    Victoria, Canada
    MS-Off Ver
    2003 & 2010
    Posts
    1,797

    Re: Match function nested in an If statement

    Hi dforte,

    Okay, this should meet the requirement for your second post:

    Code:
    =IF(AND(NOT(ISNA(MATCH(B5,'FY 06'!$B$5:$B$24,0))),'FY 06'!K5=1),0,1)
    But note in your first post where you said, "and has a "1" in both columns K of each sheet". This appears to be contradictory.

    Cheers,
    Docendo discimus.

    Please consider:
    • Thanking those who helped you. Click the reputation icon in the contributor's post and add Reputation.
    • Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

  5. #5
    Registered User
    Join Date
    12-09-2009
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    55

    Re: Match function nested in an If statement

    Hi ConneXionLost,

    Thanks for the quick reply. I'm probably having difficulty articulating what I'm trying to do. I think the first formula you posted was closer to what I am looking for because it still references column K from the second sheet in the AND statement.

    The one thing it seems the formula does not account for is:

    If a new client name appears on the second sheet (that is not existent on the first sheet), and no growth occurred ('0' in K), I would still like the formula to return '0'.

    Everything else seems to work well...

  6. #6
    Forum Moderator ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    Victoria, Canada
    MS-Off Ver
    2003 & 2010
    Posts
    1,797

    Re: Match function nested in an If statement

    Hi dforte,

    Ah! Sorry, my bad for not seeing that part! How about this one:

    Code:
    =IF(AND(NOT(ISNA(MATCH(B5,'FY 06'!$B$5:$B$24,0))),K5=1,'FY 06'!K5=1),0,IF(ISNA(MATCH(B5,'FY 06'!$B$5:$B$24,0)),0,1))
    Cheers,
    Docendo discimus.

    Please consider:
    • Thanking those who helped you. Click the reputation icon in the contributor's post and add Reputation.
    • Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

  7. #7
    Registered User
    Join Date
    12-09-2009
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    55

    Re: Match function nested in an If statement

    It's almost perfect...

    The only problems I see now are:

    If a client sees no growth ('0' in K) in the first and second sheets, it returns '1'. Here I would like to see '0' because no growth occurred.

    If a client sees no growth in the first sheet ('0' in K), but growth ('1' in K) in the second, it returns '0'. Here I would like to see a '1' because this is the first instance of growth for this specific client.

    I really appreciate your help on this...

  8. #8
    Registered User
    Join Date
    12-09-2009
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    55

    Re: Match function nested in an If statement

    just realized the problem... We're assuming that the two K cells correspond to the same person, however, it is possible between sheets that there are more names offsetting the place of the same two names...

    Is there a way to make the "'FY 06'!K5=1" within the AND statement correspond to the name that it is looking for within the MATCH statement?
    Last edited by dforte; 12-09-2009 at 03:52 AM.

  9. #9
    Forum Moderator ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    Victoria, Canada
    MS-Off Ver
    2003 & 2010
    Posts
    1,797

    Re: Match function nested in an If statement

    Hi dforte,

    Again, I'm confused by how this seems to contradict what your first post says:


    "if column K of sheet 2 and sheet 1 display a "1", I want it to place a 0 in the formula cell."
    and your most recent:


    "If a client sees no growth ('0' in K) in the first and second sheets, it returns '1'. Here I would like to see '0' because no growth occurred."
    Perhaps you might clarify what a 1 and a 0 mean in column K, as well as column L (your formula result).

    Cheers,
    Docendo discimus.

    Please consider:
    • Thanking those who helped you. Click the reputation icon in the contributor's post and add Reputation.
    • Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

  10. #10
    Registered User
    Join Date
    12-09-2009
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    55

    Re: Match function nested in an If statement

    Within column K, a 1 represents growth and a 0 represents no growth.

    Column L was my attempt at accomplishing what I am hoping you will be able to help me with. I would like to replace column L with this new formula.

    I think the best way I can describe what I would like this function to do is:

    Measure the first instance of growth (the first time a client sees 1 in column K). There will be instances where a client will be included on both sheets and I do not want to count this growth twice.

    Is this explanation more helpful?

  11. #11
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,379

    Re: Match function nested in an If statement

    If I've understood, could you not perhaps simplify to something like the below ?

    Code:
    FY07!L5: =MAX(0,$K5-SUMIF('FY 06'!$B:$B,$B5,'FY 06'!$K:$K))
    The above will take current growth (0/1) and subtract from that the growth figure on FY06 sheet

    So to surmise you end up with a truth table like

    Code:
    	prior	
    current	0	1
    0	0	-1
    1	1	0
    The use of MAX ensures it never drops below 0, ie current growth = 0 and prior growth = 1 would otherwise generate -1

    If the FY07 name does not exist on FY06 the SUMIF will return 0 by default.

  12. #12
    Registered User
    Join Date
    12-09-2009
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    55

    Re: Match function nested in an If statement

    Well, clients names will be listed from sheet to sheet. Sheets may include the same person, however not necessarily in the same corresponding row between sheets. I want to measure the first instance of growth. I think this is really close:

    =IF(AND(NOT(ISNA(MATCH(B5,'FY 06'!$B$5:$B$24,0))),K5=1,'FY 06'!K5=1),0,IF(ISNA(MATCH(B5,'FY 06'!$B$5:$B$24,0)),0,1))

    I think it would be perfect if I could ensure that the "'FY 06'!K5=1" within the AND statement would correspond to the same name that the match function is searching for.

    Thank you for your help... any further suggestions?

  13. #13
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,379

    Re: Match function nested in an If statement

    I see no reason why the prior SUMIF based suggestion won't work for you...*

    It matters not one iota to the SUMIF approach as to where a given person resides on the prior sheet nor if they fail to reside on the sheet at all - it will simply return the associated K value (0 if they do not exist)

    Other than that I'm afraid I can't help - everything else would appear to be over engineering.

    Did you try the suggestion ?

    *that being said - if the client appears Multiple times on the prior sheet that's different - but if that's the case the existing route you're taking would fail also - you'd need to revert to a LOOKUP based approach

  14. #14
    Registered User
    Join Date
    12-09-2009
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    55

    Re: Match function nested in an If statement

    You're absolutely right! If there were additional sheets, i.e. FY 10, 11, and I want to do the same check through multiple sheets, how would I accomplish this? Sumifs?

  15. #15
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,379

    Re: Match function nested in an If statement

    Quote Originally Posted by dforte
    If there were additional sheets, i.e. FY 10, 11, and I want to do the same check through multiple sheets, how would I accomplish this? Sumifs?
    No, I'm afraid not. You can not conduct conditional calculations in 3D easily.

    Can you outline what you want to do with the multiple sheets as clearly as possible ?

    To me it seems that the if the name appears on the prior sheet (FY06) then all other sheets prior to that point (eg FY04, FY05) are irrelevant - ie the prior year stipulates current growth (and is itself by it's design based upon on FY05, in turn dependent upon FY04)

    The sheets prior to prior year are only seemingly important if the client did not appear on the prior sheet (FY06) but did appear on either of FY04 / FY05 given you would need to base your FY07 calc on whichever was the last sheet the client appeared in, is that correct ?

    If so... my first instinct would be to use a common range on each sheet which keeps a running check on "current" growth as at that year for each client - using the prior sheet client listing contents plus any "new" clients to populate the current client listing...

    However to be clear without VBA (ie formulae alone) this is a non-trivial exercise.

    The other alternative is to use VBA and create a User Defined Function to calculate this which iterates sheets backwards until such time as client is found.

    If you could provide a more detailed sample file which illustrates setup and desired results that would be helpful.
    Last edited by DonkeyOte; 12-09-2009 at 05:14 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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.2.0