+ Reply to Thread
Results 1 to 14 of 14

Using IF, AND, OR, NOT Function in Conjunction

  1. #1
    Registered User
    Join Date
    03-28-2017
    Location
    Toronto
    MS-Off Ver
    2013
    Posts
    7

    Unhappy Using IF, AND, OR, NOT Function in Conjunction

    Hi,

    I have been spending much time on working with IF functions to generate a bonus based on a few conditions. I have tried compiling a complex if function into ONE column but it doesn't pull the data when I drag the formula down and into a cell where a bonus should be given.

    Here is the spreadsheet I am working with Paying a Bonus.xlsx

    Functions List_Question.JPG

    =IF($I14="Quebec",IF($O14<'Bonus Pay'!$B$3,"no bonus",IF($O14<'Bonus Pay'!$B$4,'Bonus Pay'!$A$3,'Bonus Pay'!$A$4)),IF(I14="Alberta, British Colombia, Manitoba, New Foundland, Nova Scotia, Ontario, Saskatchewan",IF($O14<'Bonus Pay'!$E$3,"no bonus",IF($O14<'Bonus Pay'!$E$4,'Bonus Pay'!$D$3,IF($O14<'Bonus Pay'!$E$5,'Bonus Pay'!$D$4,'Bonus Pay'!$D$5)))))

    I am not familiar with what overlapping function to use (is this a IF AND function, IF NOT function (to condense the provinces to "not Quebec"))

    My conditions are as follows:

    For Quebec:
    If sales/hr < 90, no bonus
    If sales/hr > = 90, pay $25 bonus
    If sales/hr > = 160, pay $50 bonus

    For the Rest of Canada:
    If sales/hr < 150, no bonus
    If sales/hr >= 150, pay $25 bonus
    If sales/hr >= 225, pay $50 bonus
    If sales/hr >= 325, pay $100 bonus

    For London Drugs (banner column)
    If sales/hr < 125, no bonus
    If sales/hr >= 125, pay $25 bonus
    If sales/hr >= 200, pay $50 bonus
    If sales/hr >= 300, pay $100 bonus

    If someone can point me in the right direction on how to write this and even if the above is partially right i am not sure where i am messing up the rest. I probably lack some basic excel knowledge that is throwing me off too. I'd really appreciate it if someone can help me get this more specific (I'm open to new ideas on how to make it cleaner as well).

    Thank you

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,823

    Re: Using IF, AND, OR, NOT Function in Conjunction

    Since it looks like the main thrust of the formula is to choose between 3 different lookups, I would probably use lookup functions [INDEX(MATCH())] for the lookup parts, then IF() functions to specify which lookup. Something like =IF(F4="London Drugs",london drugs lookup,IF(I4="Quebec",Quebec lookup,Canada lookup))

    That's how I would approach the outer IF() part of the function. Do you know how to set up the lookups, or will you need help with that, too?
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Registered User
    Join Date
    03-28-2017
    Location
    Toronto
    MS-Off Ver
    2013
    Posts
    7

    Re: Using IF, AND, OR, NOT Function in Conjunction

    Thanks for replying MrShorty!

    Do you recommend I compile the formula into one column? Or keep it as is?

    I also have only used a VLOOKUP function..

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,823

    Re: Using IF, AND, OR, NOT Function in Conjunction

    I am not sure what you are asking about when you ask about compiling into a single column. Perhaps I assumed that the goal was to compile the three bonus columns into one, but it certainly is not necessary. If you need separate columns, then keep them separate.

    the VLOOKUP() function could work just fine here, if you rearrange your lookup tables so that "sales/hr" is the left column in the lookup tables rather than the right column. If you are more familiar and more comfortable with VLOOKUP(), I would suggest you make that change and use the VLOOKUP() function instead of INDEX(MATCH()).

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Using IF, AND, OR, NOT Function in Conjunction

    How would you ID which table to use?

    Im thinking that using names ranges of your tables would work?

    1. change the order of your tables, put Sales/Hour 1st
    2. add a row to show 0 sales and 0 bonus
    3. give each table a name (I used Quebec, London and Other)
    4. make sure you have real numbers in the tables, your Quebec table contains text Bonus amounts

    A
    B
    C
    D
    E
    F
    G
    H
    I
    J
    K
    L
    M
    N
    O
    P
    Q
    2
    Monday
    3/1/2017
    12
    17
    5
    Shoppers
    1
    Shoppers-1 Ontario Orangeville
    $ 1,424.58
    $ 284.92
    $ 50
    3
    Monday
    3/2/2017
    12
    17
    5
    Rexall
    2
    Rexall-2 Ontario Georgetown
    $ 720.80
    $ 144.16
    $ -
    4
    Tuesday
    3/3/2017
    11.5
    16.5
    5
    London Drugs
    3
    London Drugs-3 Ontario Woodbridge
    $ 624.48
    $ 124.90
    London
    $ -
    5
    Tuesday
    3/4/2017
    11.5
    16.5
    5
    Shoppers
    4
    Shoppers-4 Alberta Calgary
    $ 719.00
    $ 143.80
    $ -
    6
    Monday
    3/5/2017
    11
    15
    4
    Shoppers
    5
    Shoppers-5 Nova Scotia Halifax
    $ 98.98
    $ 24.75
    $ -
    7
    Monday
    3/6/2017
    12
    16
    1
    Rexall
    6
    Rexall-6 Quebec Quebec
    $ 108.69
    $ 108.69
    Quebec
    $ 25
    8
    Tuesday
    3/7/2017
    12
    16
    4
    London Drugs
    7
    London Drugs-7 Ontario Burlington
    $ 627.48
    $ 156.87
    London
    $ 25
    9
    Tuesday
    3/8/2017
    12
    16
    4
    Rexall
    8
    Rexall-8 Quebec Quebec
    $ 134.00
    $ 33.50
    Quebec
    $ -


    I put the location in P, then...
    Q2=VLOOKUP(O2,INDIRECT(IF(P2="","Other",P2)),2,1)
    copied down
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  6. #6
    Registered User
    Join Date
    03-28-2017
    Location
    Toronto
    MS-Off Ver
    2013
    Posts
    7

    Re: Using IF, AND, OR, NOT Function in Conjunction

    By "compiling" into a single column I meant i'd like to have one formula look up all of these conditions and populates a bonus or not.

    I found with vlookup i wasn't able to do that so maybe if i created separate columns for the three conditions it may be less complex. Would there be an option to create one formula?

  7. #7
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,823

    Re: Using IF, AND, OR, NOT Function in Conjunction

    I am not sure I understand what you are stuck.

    Using a divide and conquer strategy, maybe let's focus on getting the lookups to work correctly. Row 2 should be pulling from the "rest of Canada" table, so does =INDEX($D$15:$D$17,MATCH(O2,$E$15:$E$17,1)) in M2 return the correct value?

  8. #8
    Registered User
    Join Date
    03-28-2017
    Location
    Toronto
    MS-Off Ver
    2013
    Posts
    7

    Re: Using IF, AND, OR, NOT Function in Conjunction

    Yes it does! that works

  9. #9
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,823

    Re: Using IF, AND, OR, NOT Function in Conjunction

    Copied down, that should work for row 2 and row 8, but should return N/A for the others (because the sales/hr for the other rows is less than 150). If you added a row to the top of the "rest of Canada" table (above the 25 -- 150 entry) that was 0 -- 0 (and adjusted the references in the match and index functions), then it should work correctly for all rows. You should then be able to do something similar for N2 (for London drugs) and L2 (for Quebec).

    Once you have each lookup working correctly, then a simple IF() function (similar to what I showed in post #2) should be able to choose between the three lookups. If you want to go further, they could all be nested together into a single nested function.

    Can you get all three lookups working for all rows?

  10. #10
    Registered User
    Join Date
    03-28-2017
    Location
    Toronto
    MS-Off Ver
    2013
    Posts
    7

    Re: Using IF, AND, OR, NOT Function in Conjunction

    Ok all three columns are working! PLus i've added the 0-0 row in each table array.

    Back to my stricky IF function, how can I take the next step to create the correct IF function between the three lookups. Ideally take it further afterwards and nest into a single nested function (this is the step i've been tirelessly working towards getting..)

  11. #11
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,823

    Re: Using IF, AND, OR, NOT Function in Conjunction

    Assuming those functions are working, now put them into the IF() function I posted in #2: =IF(F4="London Drugs",london drugs lookup,IF(I4="Quebec",Quebec lookup,Canada lookup))
    Replace the "london drugs lookup" with the INDEX(...,MATCH(...)) function that you have in column N (without the leading = sign).
    Replace the "Quebec lookup" with the INDEX(...,MATCH(...)) in column L
    and so on.

  12. #12
    Registered User
    Join Date
    03-28-2017
    Location
    Toronto
    MS-Off Ver
    2013
    Posts
    7

    Re: Using IF, AND, OR, NOT Function in Conjunction

    This works for London Drugs:
    =IF(F2="London Drugs", INDEX($G$15:$G$18,MATCH(P2,$H$15:$H$18,1)))

    For the rest of Canada, should i name all of the other provinces? and implement the same formula above?


    I have tried piecing it together into ONE column (added column L beside "QC Bonus") but it wouldn't work - it says there are too many functions for this formula to work:

    =IF(F2="London Drugs", INDEX($G$15:$G$18,MATCH(P2,$H$15:$H$18,1))), IF(I2="Quebec", INDEX(A15:A17,MATCH(P2,B15:B17,1))),IF(I2="Ontario","Alberta","Nova Scotia","Manitoba","British Columbia", "Saskatchewan", "Newfoundland", "New Brunswick", "Prince Edward Island", INDEX(D15:D18,MATCH(P2,E15:E18,1)))

    Issue With Final Steps.JPG

  13. #13
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,823

    Re: Using IF, AND, OR, NOT Function in Conjunction

    This variation =IF(F2="London Drugs", INDEX($G$15:$G$18,MATCH(P2,$H$15:$H$18,1))) leaves the value if false argument empty, so this function will perform the lookup when F2="london drugs" but will return FALSE when F2=anything else. Note that in my version, I put another IF() function in the value_if_false argument to test for Quebec. My function assumes that if it is neither a london drug lookup nor a quebec lookup that it should perform the rest of canada lookup. Is it necessary to perform the last "is I2="ontario" or "alberta" or..."? My example has assumed that if it is neither longond drugs nor quebec that the rest of canada lookup will apply. Are there other cases to consider?

    This variation =IF(F2="London Drugs", INDEX($G$15:$G$18,MATCH(P2,$H$15:$H$18,1))), IF(I2="Quebec", INDEX(A15:A17,MATCH(P2,B15:B17,1))),IF(I2="Ontario","Alberta","Nova Scotia","Manitoba","British Columbia", "Saskatchewan", "Newfoundland", "New Brunswick", "Prince Edward Island", INDEX(D15:D18,MATCH(P2,E15:E18,1))) has multiple completely separate IF() functions separated by commas, which Excel does not know how to handle. Excel also does not know what I2="ontario","alberta",... means. I know that you mean if I2="ontario" or I2="alberta" or .... (in other words, you mean an OR() function, and this is not the correct syntax for an OR() function). To use the OR() function like this, you might do =IF(OR(I2="ontario",I2="alberta",I2="Nova Scotia",...),what to do if true, what to do if false).

    The basic syntax of the IF() function is straightforward, and I would recommend that you spend some time thinking it through. The example I gave should do this in one nested IF().

  14. #14
    Registered User
    Join Date
    03-28-2017
    Location
    Toronto
    MS-Off Ver
    2013
    Posts
    7

    Re: Using IF, AND, OR, NOT Function in Conjunction

    Thank you! the OR function; i've been looking into this as well.. i am very new to excel so i will spend more time looking into this.

    I'll respond with my final edition.

+ 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. Vlookup in conjunction with Index and CountA function
    By manning457 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-27-2015, 02:26 PM
  2. Application.Transpose in conjunction with Last Row
    By jquintana83 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-30-2014, 02:34 PM
  3. [SOLVED] Using Solver in conjunction with VBA
    By sminter in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-30-2014, 02:05 PM
  4. If / then help - conjunction
    By sambuka in forum Excel General
    Replies: 4
    Last Post: 06-23-2012, 03:48 PM
  5. Replies: 2
    Last Post: 03-29-2012, 07:52 AM
  6. Utilizing iteration in conjunction with Excel function
    By Squash_Pro in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-03-2008, 03:37 AM
  7. [SOLVED] Using IF & AND command in conjunction
    By KDD in forum Excel General
    Replies: 7
    Last Post: 08-25-2005, 12: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