+ Reply to Thread
Results 1 to 17 of 17

Need help with applying conditional formulas!

  1. #1
    Registered User
    Join Date
    08-26-2016
    Location
    Hawaii. USA
    MS-Off Ver
    Excel 2010, 2013, 2016
    Posts
    24

    Need help with applying conditional formulas!

    Hi all,

    I have a real simple (and possibly dumb) question. Why doesn't my sumproduct return the expected value?

    Here's my formula (in G83):

    =SUMPRODUCT(--(E83="AD")*(D83+G12),--(E83="dscvry")*(D83+F83),--(E83="CD")*(D83+G13),--(E83="AD-B")*(D83+H13),--(E83="receipt")*(D83+F83),--(E83="CD-B")*(D83+H13),--(E83="SCD")*(D83+G13))

    Here's what my table looks like:

    Ref / ! / Item / Days / Label / Contingent Date / Projected Date / Completed Date
    H4 / 1 / Table Delivery / 5 / receipt / 12-5-2016 / [formula] 12-10-2016 / ---- [manual entry later]


    The cells I'm adding together are dates and numbers of days to come up with a new date. For example, D83 is "5" days and F83 is "12/5/2016", which should give me "12/10/2016" in G83. What I'm trying to do is have SUMPRODUCT check the "LABEL" of the row it's in (83 in this example) for a matching text entry and return a corresponding formula. So, if E83 has "receipt", sumproduct would return the sum of "D83+F83" and zero from the rest. The label field could also contain CD, AD, SCD, etc. Each one of these "labels" has it's own formula.

    The problem is, the result of my formula is 0. Sumproduct isn't multiplying them, is it? My understanding is it's 0+0+0+0+0+0+23446+0+0, and not 0*0*0*0*0*57423*0*0. By the way, I don't need to use sumproduct, but this seems like a simple task and I'm stuck.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Need help with applying conditional formulas!

    Hi,

    You'd be better advised to upload the workbook so that we can see the request in context.
    Manually add the results you expect and clearly identify which cells are data and which are results, and in a note explain how you have arrived at the results with reference to the data and any rules you apply.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Need help with applying conditional formulas!

    Hi,

    You'd be better advised to upload the workbook so that we can see the request in context.
    Manually add the results you expect and clearly identify which cells are data and which are results, and in a note explain how you have arrived at the results with reference to the data and any rules you apply.

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Need help with applying conditional formulas!

    Quote Originally Posted by hawaean View Post
    =SUMPRODUCT(--(E83="AD")*(D83+G12),--(E83="dscvry")*(D83+F83),--(E83="CD")*(D83+G13),--(E83="AD-B")*(D83+H13),--(E83="receipt")*(D83+F83),--(E83="CD-B")*(D83+H13),--(E83="SCD")*(D83+G13))
    In "plain English" your formula is saying:

    If E83="AD" AND E83="dscvry" AND E83="CD" AND E83="AD-B" AND E83="receipt" AND E83="CD-B" AND E83="SCD" ...

    The problem is that E83 CAN'T meet all those conditions at the same time!
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  5. #5
    Registered User
    Join Date
    08-26-2016
    Location
    Hawaii. USA
    MS-Off Ver
    Excel 2010, 2013, 2016
    Posts
    24

    Re: Need help with applying conditional formulas!

    Quote Originally Posted by Tony Valko View Post
    In "plain English" your formula is saying:

    If E83="AD" AND E83="dscvry" AND E83="CD" AND E83="AD-B" AND E83="receipt" AND E83="CD-B" AND E83="SCD" ...

    The problem is that E83 CAN'T meet all those conditions at the same time!
    Great response Tony. How do I state the same thing, but with an "or"?

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Need help with applying conditional formulas!

    =IF(OR(E83="AD",E83="dscvry",E83="CD",......),this,that)

    perhaps.

    But why not upload the workbook. There may be easier ways of achieving what you want

  7. #7
    Registered User
    Join Date
    08-26-2016
    Location
    Hawaii. USA
    MS-Off Ver
    Excel 2010, 2013, 2016
    Posts
    24

    Re: Need help with applying conditional formulas!

    See attached sample worksheet.

    NOTE: The other date formulas do work on my original spreadsheet (rows 6-18), but cutting down the data, the references got messed up and those dates do not apply.
    Attached Files Attached Files
    Last edited by hawaean; 12-03-2016 at 06:19 PM.

  8. #8
    Registered User
    Join Date
    08-26-2016
    Location
    Hawaii. USA
    MS-Off Ver
    Excel 2010, 2013, 2016
    Posts
    24

    Re: Need help with applying conditional formulas!

    Quote Originally Posted by Richard Buttrey View Post
    =IF(OR(E83="AD",E83="dscvry",E83="CD",......),this,that)

    perhaps.

    But why not upload the workbook. There may be easier ways of achieving what you want
    Sorry Richard. Was just having noob issues getting the worksheet online. - Cheers

  9. #9
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Need help with applying conditional formulas!

    I didn't download your file.

    =SUMPRODUCT(--(E83="AD")*(D83+G12),--(E83="dscvry")*(D83+F83),--(E83="CD")*(D83+G13),--(E83="AD-B")*(D83+H13),--(E83="receipt")*(D83+F83),--(E83="CD-B")*(D83+H13),--(E83="SCD")*(D83+G13))
    The formula looks like it can be written as a nested IF formula as you're testing E83 for various contents and each variable has its own result.

    The results are all D83+some other cell.

    If none of the conditions are met what result do you expect?

  10. #10
    Registered User
    Join Date
    08-26-2016
    Location
    Hawaii. USA
    MS-Off Ver
    Excel 2010, 2013, 2016
    Posts
    24

    Re: Need help with applying conditional formulas!

    Quote Originally Posted by Tony Valko View Post
    I didn't download your file.


    The formula looks like it can be written as a nested IF formula as you're testing E83 for various contents and each variable has its own result.

    The results are all D83+some other cell.

    If none of the conditions are met what result do you expect?
    If none of the conditions are met, then I'd like it to return the text "NA".

  11. #11
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Need help with applying conditional formulas!

    Please clarify the reference to D83. The workbook you've uploaded only goes down to row 21.

    Also please manually add rge results you expect to see in column G in say column I so that we can understand the end goal. Explain in some notes how yuo've calculated the results.

  12. #12
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Need help with applying conditional formulas!

    Quote Originally Posted by hawaean View Post
    If none of the conditions are met, then I'd like it to return the text "NA".
    OK, this "emulates" the SUMPRODUCT function:

    =IF(E83="AD",D83+G12,IF(OR(E83={"dscvry","receipt"}),D83+F83,IF(OR(E83={"CD","SCD"}),D83+G13,IF(OR(E83={"AD-B","CD-B"}),D83+H13,"NA"))))

    Whether that's what you actually need/want is another story!

  13. #13
    Registered User
    Join Date
    08-26-2016
    Location
    Hawaii. USA
    MS-Off Ver
    Excel 2010, 2013, 2016
    Posts
    24

    Re: Need help with applying conditional formulas!

    Quote Originally Posted by Richard Buttrey View Post
    Please clarify the reference to D83. The workbook you've uploaded only goes down to row 21.

    Also please manually add rge results you expect to see in column G in say column I so that we can understand the end goal. Explain in some notes how yuo've calculated the results.
    Richard, my original post referred to cells in my actual workbook. The sample sheet I uploaded does not have the same number of rows and the data is different as well. Please see the highlighted notes on the worksheet itself.

    Subject formula is in cell G21. The operation should be that the formula looks at E21 and understands what to do with D21. In some cases, G21 will add D21 to F21. In other cases, D21 is added to G2, H3 or H4.

    All that being said, I'm not so concerned with the operations after G21 figures out what to do. I just figured there was an easy way to set up a formula in G21 to check E21 and spit out different formulas depending on what it finds.

    Thanks.

  14. #14
    Registered User
    Join Date
    08-26-2016
    Location
    Hawaii. USA
    MS-Off Ver
    Excel 2010, 2013, 2016
    Posts
    24

    Re: Need help with applying conditional formulas!

    Quote Originally Posted by Tony Valko View Post
    OK, this "emulates" the SUMPRODUCT function:

    =IF(E83="AD",D83+G12,IF(OR(E83={"dscvry","receipt"}),D83+F83,IF(OR(E83={"CD","SCD"}),D83+G13,IF(OR(E83={"AD-B","CD-B"}),D83+H13,"NA"))))

    Whether that's what you actually need/want is another story!
    Functionally, that accurately works (in my actual workbook). I'm a bit stumped on why there isn't a less cumbersome way to accomplish this tho. Any thoughts?

  15. #15
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Need help with applying conditional formulas!

    If you create a small 2 column table then you can use a more compact formula.

    You would put the text variable in the left column and its corresponding numeric value in the right column (in this case, a formula). For example:

    Data Range
    A
    B
    1
    AD
    =D83+G12
    2
    dscvry
    =D83+F83
    3
    receipt
    =D83+F83
    4
    CD
    =D83+G13
    5
    SCD
    =D83+G13
    6
    AD-B
    =D83+H13
    7
    CD-B
    =D83+H13


    Then, the formula to replace the nested IF would be:

    =IFERROR(VLOOKUP(E83,A1:B7,2,0),"NA")

  16. #16
    Registered User
    Join Date
    08-26-2016
    Location
    Hawaii. USA
    MS-Off Ver
    Excel 2010, 2013, 2016
    Posts
    24

    Re: Need help with applying conditional formulas!

    Quote Originally Posted by Tony Valko View Post
    If you create a small 2 column table then you can use a more compact formula.

    You would put the text variable in the left column and its corresponding numeric value in the right column (in this case, a formula). For example:

    Data Range
    A
    B
    1
    AD
    =D83+G12
    2
    dscvry
    =D83+F83
    3
    receipt
    =D83+F83
    4
    CD
    =D83+G13
    5
    SCD
    =D83+G13
    6
    AD-B
    =D83+H13
    7
    CD-B
    =D83+H13


    Then, the formula to replace the nested IF would be:

    =IFERROR(VLOOKUP(E83,A1:B7,2,0),"NA")
    Hi Tony,

    If I filled this formula down, would the "key" follow and return D84 when checking E84?

    It's totally fine if I need to go with the original formula you posted.

  17. #17
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Need help with applying conditional formulas!

    Quote Originally Posted by hawaean View Post
    If I filled this formula down, would the "key" follow and return D84 when checking E84?
    Not sure I understand.

    If you want to copy the formula down a column then you'd make the references to the lookup table absolute:

    =IFERROR(VLOOKUP(E83,A$1:B$7,2,0),"NA")

+ 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. [SOLVED] Applying Data Validation to Allow Only Formulas
    By loverfellow in forum Excel General
    Replies: 5
    Last Post: 12-03-2015, 12:32 AM
  2. Replies: 5
    Last Post: 09-05-2014, 11:30 AM
  3. need help applying formulas to multiple rows
    By pdc in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-18-2012, 01:18 AM
  4. Replies: 0
    Last Post: 08-08-2011, 10:08 AM
  5. applying formulas using cell references
    By engrpetero in forum Excel General
    Replies: 6
    Last Post: 12-18-2009, 05:21 PM
  6. Applying formulas to lots of data
    By Trothwell in forum Excel General
    Replies: 5
    Last Post: 07-20-2009, 08:56 AM
  7. [SOLVED] Applying Formulas to Visible Cells Only
    By SteveC in forum Excel General
    Replies: 7
    Last Post: 06-26-2006, 06:50 PM

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