We're aware that some users are experiencing technical issues which the team are working to resolve. See the Community Noticeboard for more info. Thank you for your patience.
📨 Have you signed up to the Forum's new Email Digest yet? Get a selection of trending threads sent straight to your inbox daily, weekly or monthly!

Excel Formula Help

Options
I'm trying to compare some values in Excel. What I'd like is a formula that will take the result (W/L) in column G and then if W will put the sum of D & F columns in column H and if L will put 0. At the moment I've got the first half of the formula =IF(G2="W",D2*F2), but column H is showing as False and ideally I'd like it to show 0. Does anyone know ow to do this? I've tried Googling but I never get quite what I want. Thanks.

Comments

  • You just need to add an element to your formula, try:

    =IF(G2="W",D2*F2,0)

  • Kido250
    Kido250 Posts: 101 Forumite
    Part of the Furniture 10 Posts
    Perfect. Knew it it would be easy once I knew the answer.
  • Heedtheadvice
    Heedtheadvice Posts: 2,765 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    edited 1 April 2021 at 11:30AM
    Perfect? Far from it!!
    That formula might give you the answer you need... (If indeed the maths was correct!!!)
    But it does not give you the answer you asked for!
    "if W will put the sum of D & F columns in column H and if L will put 0"
    It will do the multiplication answer but will give you 0 for all other values of col G. You asked for zero when G is L! For that you need to add another if statement to give 0 for L and a default value (like the 0 in that first if statement) for all other values.
    That might not matter of course if you just happened to phrase your question incorrectly?
    The formula ought to be:
    =IF(G2="W",D2+F2,0) (not a multiplication but an addition)
    or
    =IF(G2="W",D2+F2,IF(G2="L",0, a default value or text))

    Consider what result you would want, for example if cell in col G was X or held no value (or for that matter an error value or #n/a if it is a calculated cell)



  • Kido250
    Kido250 Posts: 101 Forumite
    Part of the Furniture 10 Posts
    Thanks for the help. I now have 5 formals which work independently but I need to put them together so the answer comes out depending on whether a, b, c, d or e is in cell G17. The 5 formulas I have are:
    =IF(G17="a",(D17/2)*D17/5+D17/2)
    =IF(G17="b",(D17/2)*F17+(D17/2)*D17/5+D17/2)
    =IF(G17="c",(D19))
    =IF(G17="d",0)
    =IF(G17="e",(D17*F17))
    Is this possible?
  • Could use nested IF formulae but messy. Simplest is:
    =IF(G17="a",(D17/2)*D17/5+D17/2,0)+IF(G17="b",(D17/2)*F17+(D17/2)*D17/5+D17/2,0)+IF(G17="c",(D19),0)+IF(G17="d",0)+IF(G17="e",(D17*F17),0)
    with no spaces anywhere.

  • Heedtheadvice
    Heedtheadvice Posts: 2,765 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    Are you sure this is what you mean..=IF(G17="a",(D17/2)*D17/5+D17/2)....
    Do check your maths and order of calculation!

    Far better to do individual formulas in columns next to each other and then just select the column based upon col G's contents for the final answer....just one other way of doing- it because as wayward says long nested formulae are not the simplest to view and are therefore prone to mistakes. Not as bad with named ranges but that's another matter.
  • moneysavinghero
    moneysavinghero Posts: 1,761 Forumite
    1,000 Posts Fourth Anniversary Name Dropper Photogenic
    Newer versions of Excel have the SWITCH function which makes things a little less messy than using lots of nested IF's
    =SWITCH(G17,"A",value,"B",value,"C",value,"D",value",E",value, default)
    Replace value with values (or formulas) you want and replace default with a default value
  • Newer versions of Excel have the SWITCH function which makes things a little less messy than using lots of nested IF's
    =SWITCH(G17,"A",value,"B",value,"C",value,"D",value",E",value, default)
    Replace value with values (or formulas) you want and replace default with a default value
    You learn something new every day! Available from Office 2019. Not case-dependent so "a" same as "A".
Meet your Ambassadors

🚀 Getting Started

Hi new member!

Our Getting Started Guide will help you get the most out of the Forum

Categories

  • All Categories
  • 350.8K Banking & Borrowing
  • 253K Reduce Debt & Boost Income
  • 453.5K Spending & Discounts
  • 243.8K Work, Benefits & Business
  • 598.6K Mortgages, Homes & Bills
  • 176.8K Life & Family
  • 257.1K Travel & Transport
  • 1.5M Hobbies & Leisure
  • 16.1K Discuss & Feedback
  • 37.6K Read-Only Boards

Is this how you want to be seen?

We see you are using a default avatar. It takes only a few seconds to pick a picture.