Page 1 of 1

[Solved] Almost There - IF Statement

Posted: Thu Apr 11, 2019 8:34 pm
by quarkrad
The attached shows how much to add to a unit price of £80, £4 if the drop down in A7 is "good". I would like to add to the formula in E5 such that if A7 is changed to "bad" then D3 is added to B3. I've tried a number of variants but no luck so far.

Re: Almost There - IF Statement

Posted: Thu Apr 11, 2019 8:41 pm
by quarkrad
Not sure if this is the most effective but =IF(A7="good",B3+C3,IF(A7="bad",B3+D3)) appears to work.

Re: Almost There - IF Statement

Posted: Thu Apr 11, 2019 9:47 pm
by jeffs12
If A7 is ALWAYS and ONLY "good" or "bad", you don't need the nested IF() statement; a simple =IF(A7="good";B3+C3;B3+D3) is all you need. The result is that any value (or lack of value) in A7, other than "good", will result in B3+D3.
If A7 may be blank, or some other value, use your nested IF() statement, but add the otherwise parameter after the B3+D3 to display what you want in E5 if A7 is neither "good" nor "bad".

Re: Almost There - IF Statement

Posted: Thu Apr 11, 2019 10:06 pm
by quarkrad
Thank you very much - I think I'm beginning to understand this LITTLE bit. Appreciate your help.

Re: Almost There - IF Statement

Posted: Thu Apr 11, 2019 10:11 pm
by RusselB
A slight re-write of jeffs12's code, just to give you another option, could be

Code: Select all

=B3+if(A7="good";C3;D3)

Re: Almost There - IF Statement

Posted: Thu Apr 11, 2019 11:06 pm
by Villeroy
if the first argument evaluates to TRUE then return the second argument (if_true) value, otherwise return the third argument (if_false) value:
IF(condition ; if_true ; if_false)
nested, branching from the false:
IF(condition1 ; if1_true ; IF(condition2 ; if2_true ; if2_false))
or branching from the true:
IF(condition1 ; IF(condition2 ; if2_true ; if2_false) ; if1_false)

In your formula which branches from the false:
IF(A7="good" ; B3+C3 ; IF(A7="bad" ; B3+D3))
the if2_false is missing. The inner IF has only 2 arguments as in:
IF(condition ; if_true )
When the third argument to IF is missing, the function returns FALSE (equivalent to 0) in case of false as you can see when you put anything else A7 that is not "good" or "bad".

Personally, I try my best to avoid any use of IF. And I avoid words with special meanings such as "good" or "bad". They add unnecessary complexity.