+ Reply to Thread
Results 1 to 8 of 8

IF Function 20 scenarios =(

  1. #1
    Registered User
    Join Date
    06-12-2019
    Location
    NJ, US
    MS-Off Ver
    2016
    Posts
    3

    IF Function 20 scenarios =(

    Hi Everyone! So my excel partner in crime ( well I was more his sidekick lol ) quit = ( so now I am stuck finishing his excel workbook for a project at work and this is WAY beyond me. Can anyone please throw me a bone and help me with this.

    If E3 = "Billable" and G3 = "Paper Mail" and P3 = "Yes" then R3= O3+Q3+10
    If E3 = "Billable" and G3 = "Paper Mail" and P3 = "No" then R3= O3+Q3
    If E3 = "Non-Billable" and G3 = "Paper Mail" and P3 = "Yes" then R3= Q3+10
    If E3 = "Non-Billable" and G3 = "Paper Mail" and P3 = "No" then R3 =Q3
    If E3 = "Billable" and G3 = "CD/USB Mail" and P3 = "Yes" then R3=6.50+Q3+10
    If E3 = "Billable" and G3 = "CD/USB Mail" and P3 = "No" then R3=6.50+Q3
    If E3 = "Non-Billable" and G3 = "CD/USB Mail" and P3 = "Yes" then R3=Q3+10
    If E3 = "Non-Billable" and G3 = "CD/USB Mail" and P3 = "No" then R3=Q3
    If E3 = "Billable" and G3 = "Electronic" and P3 = "Yes" then R3=6.50+10
    If E3 = "Billable" and G3 = "Electronic" and P3 = "No" then R3=6.50
    If E3 = "Non-Billable" and G3 = "Electronic" and P3 = "Yes" then R3=10
    If E3 = "Non-Billable" and G3 = "Electronic" and P3 = "No" then R3= 0
    If E3 = "Billable" and G3 = "Walk-in Paper" and P3 = "Yes" then R3= O3+10
    If E3 = "Billable" and G3 = "Walk-in Paper" and P3 = "No" then R3= O3
    If E3 = "Non-Billable" and G3 = "Walk-in Paper" and P3 = "Yes" then R3= 10
    If E3 = "Non-Billable" and G3 = "Walk-in Paper" and P3 = "No" then R3= 0
    If E3 = "Billable" and G3 = "Walk-in CD/USB" and P3 = "Yes" then R3= 6.50+10
    If E3 = "Billable" and G3 = "Walk-in CD/USB" and P3 = "No" then R3= 6.50
    If E3 = "Non-Billable" and G3 = "Walk-in CD/USB" and P3 = "Yes" then R3= 10
    If E3 = "Non-Billable" and G3 = "Walk-in CD/USB" and P3 = "Yes" then R3= 0


    Thank you very much for your help!

  2. #2
    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,936

    Re: IF Function 20 scenarios =(

    Hi, welcome to the forum

    From what I can see, something like...
    if(P3=Yes,10,0)+if(E3=billable,)3,0)+............
    See where im going on this?

    Another option might be to use a set of small tables, and use vlookup or something similar.

    Maybe upload a small (clean) sample workbook (not a pic) of what you are working with, and what your expected outcome would look like.
    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

  3. #3
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: IF Function 20 scenarios =(

    Read all this first before doing anything

    I notice if P3="Yes" then 10 is added otherwise nothing is added so that cuts out half the IFs already
    Create a table to lookup E3 and G3, the three extra columns will have 1s or 0s to multiply O3 or Q3 depending on the combination of the first two columns.
    Sounds complicated but just follow these instructions and it should work (I think)

    So you can replace all those IFs using this

    Set up a matrix 10 rows by 5 columns in Sheet2!A1 like this

    Please Login or Register  to view this content.
    You can copy this into a blank spreadsheet, let's say Sheet2 starting at A1. You may need to use text to Columns with a comma separater so you end up with 10 rows and 5 columns

    Then your formula would be (slightly tested)

    =INDEX(Sheet2!A$1:E$10,MATCH(E3,IF(G3=Sheet2!B$1:B$10,Sheet2!A$1:A$10),0),3)*O3+INDEX(Sheet2!A$1:E$10,MATCH(E3,IF(G3=Sheet2!B$1:B$10,Sheet2!A$1:A$10),0),4)*Q3+INDEX(Sheet2!A$1:E$10,MATCH(E3,IF(G3=Sheet2!B$1:B$10,Sheet2!A$1:A$10),0),5)*6.5+(P3="Yes")*10
    Array formula, use Ctrl-Shift-Enter
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: IF Function 20 scenarios =(

    Another approach:

    I'd also start from correcting
    If E3 = "Non-Billable" and G3 = "Walk-in CD/USB" and P3 = "Yes" then R3= 0
    It's probably for P3 = "No"

    Then I'd notice that P3 = yes always adds 10 to result (compared to P3 = No),

    so we have only 10 variants

    if(P3 = "Yes",10,0) +

    If E3 = "Billable" and G3 = "Paper Mail" then R3= O3+Q3
    If E3 = "Non-Billable" and G3 = "Paper Mail" then R3 =Q3
    If E3 = "Billable" and G3 = "CD/USB Mail" then R3=6.50+Q3
    If E3 = "Non-Billable" and G3 = "CD/USB Mail" then R3=Q3
    If E3 = "Billable" and G3 = "Electronic" then R3=6.50
    If E3 = "Non-Billable" and G3 = "Electronic" then R3= 0
    If E3 = "Billable" and G3 = "Walk-in Paper" then R3= O3
    If E3 = "Non-Billable" and G3 = "Walk-in Paper" then R3= 0
    If E3 = "Billable" and G3 = "Walk-in CD/USB" then R3= 6.50
    If E3 = "Non-Billable" and G3 = "Walk-in CD/USB" then R3= 0


    moreover it seems that R3 = 0 (or 10 if P3 = yes) for E3 non-billable and 3 values of G3 and R3 =Q3 for other 2 values of G3.

    For E3 = "Billable" we have only 2 cases (in G3) where R3 = 6.5



    Let's rearrange the above:

    if(P3 = "Yes",10,0) +

    If E3 = "Non-Billable" and (G3 = "Paper Mail" or G3 = "CD/USB Mail") then R3=Q3
    If E3 = "Non-Billable" and G3 is different from above then R3= 0

    If E3 = "Billable" and G3 = "Paper Mail" then R3= O3+Q3
    If E3 = "Billable" and G3 = "CD/USB Mail" then R3=6.50+Q3
    If E3 = "Billable" and G3 = "Walk-in Paper" then R3= O3
    If E3 = "Billable" and G3 is different from above then R3=6.50

    so we can write it (still informal way):

    if(P3 = "Yes",10,0) + If(E3 = "Non-Billable"

    then

    if (G3 = "Paper Mail" or G3 = "CD/USB Mail") then R3=Q3
    else
    If G3 = "Paper Mail" then R3= O3+Q3
    If G3 = "CD/USB Mail" then R3=6.50+Q3
    If G3 = "Walk-in Paper" then R3= O3
    If G3 is different from above then R3=6.50
    )

    and now real excel formula for R3
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by Kaper; 07-22-2019 at 12:34 PM. Reason: edited first lines, because Special-K already posted the answer
    Best Regards,

    Kaper

  5. #5
    Registered User
    Join Date
    06-12-2019
    Location
    NJ, US
    MS-Off Ver
    2016
    Posts
    3

    Re: IF Function 20 scenarios =(

    I am getting an Error message : #N/A , please let me know If I copied something wrong.

    Sheet 2
    Billable Paper Mail 1 1 0
    Non-Billable Paper Mail 0 1 0
    Billable CD/USB 0 1 1
    Non-Billable CD/USB 0 1 0
    Billable Electronic 0 0 1
    Non-Billable Electronic 0 0 0
    Billable Walk-in Paper 1 0 0
    Non-Billable Walk-in Paper 0 0 0
    Billable Walk-in CD/USB 0 0 1
    Non-Billable Walk-in CD/USB 0 0 0

    Cell R3
    =INDEX(Sheet2!A$1:E$10,MATCH(E2,IF(G2=Sheet2!B$1:B$10,Sheet2!A$1:A$10),0),3)*O2+INDEX(Sheet2!A$1:E$10,MATCH(E2,IF(G2=Sheet2!B$1:B$10,Sheet2!A$1:A$10),0),4)*Q2+INDEX(Sheet2!A$1:E$10,MATCH(E2,IF(G2=Sheet2!B$1:B$10,Sheet2!A$1:A$10),0),5)*6.5+(P2="Yes")*10

  6. #6
    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,936

    Re: IF Function 20 scenarios =(

    To best describe or illustrate your problem you would be better off attaching a dummy workbook. The workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    To attach a file to your post,
    click advanced (next to quick post),
    scroll down until you see "manage file",
    click that and select "add files" (top right corner).
    click "select files" find your file, click "open" click "upload" click 'done" bottom right. click "submit reply"

    Once the upload is completed the file name will appear below the input boxes in this window.
    You can then close the window to return to the new post screen.

  7. #7
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: IF Function 20 scenarios =(

    Quote Originally Posted by szucchari View Post
    I am getting an Error message : #N/A , please let me know If I copied something wrong.
    It should be an array formula as stated.
    If you enter it as a normal formula you get a #N/A error.

    Array formula, use Ctrl-Shift-Enter

    I copied the data to Sheet2!A1, did a Text to columns using comma as delimiter so the matrix now covers Sheet2!A1:E10

    In Sheet1!E3 I put Billable
    In Sheet1!G3 I put Electronic

    I entered the formula in Sheet1!A1 as an array formula and it returned the value 6.5 which is correct as P3 is blank (not Yes)

  8. #8
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: IF Function 20 scenarios =(

    Just in case - have you also noted less elegant than array formula, but probably "more traditional" solution presented in post #4 https://www.excelforum.com/excel-for...ml#post5160646 ?

+ 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. Identify parent record using IF function to combine the scenarios
    By suchetherrah in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 12-09-2015, 04:07 AM
  2. Index function to solve Scenarios
    By alive555 in forum Excel General
    Replies: 3
    Last Post: 09-18-2015, 09:41 AM
  3. Replies: 4
    Last Post: 11-13-2014, 07:42 AM
  4. Scenarios
    By annieshaw in forum Excel General
    Replies: 2
    Last Post: 10-18-2011, 08:59 PM
  5. Excel if function used for different scenarios
    By frankiebrooke in forum Excel General
    Replies: 14
    Last Post: 03-17-2011, 02:48 PM
  6. Replies: 3
    Last Post: 04-14-2010, 03:54 AM
  7. Scenarios
    By JosefS in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10: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