I hope you do enjoy this free blog. I only ask one thing from you in return, click in one of the ads

Thursday 15 January 2015

IF function

Category: Logical functions


What does this function do?


Evaluates the specified condition and returns a value if the condition is true and another value if the condition is false.


Syntax:


IF (logical_test, [value_if_true], [value_if_false])


Logical_test (required): is any value or expression that can be evaluated to TRUE or FALSE. For example, A1> 10, or A1 = "dog" or A1 = 0

Value_if_true (optional): is the value that is returned if the argument is TRUE.

Value_if_false (optional): is the value that is returned if the argument is FALSE.



Examples:


Assume A1 = 15.

= IF (A1> 0,1,0) = 1
= IF (A1 <0,1,0) = 0


Bonus:


The IF function can also evaluate other Excel formulas such as AND or OR, also other IF functions (Nested IF)

= IF (IF (A1> 0,1,0) = 1, "Great," "Bad luck")

Here we are evaluating two conditions. The first (second IF) is if the value in cell A1 is greater than 0, and if that were true, the result would return 1, and if it is false that would return a 0.
The second condition uses the result of the first, so, if the first aforementioned condition return us 1, the second is fulfilled since 1 = 1, and therefore the formula would return us "Great". If the result of the first condition be 0, the formula returns "Bad luck".

Suppose that A1 = 5

The first IF tells us that IF(5> 0,1,0) and clearly the result would be 1.
And now the formula looks like this: IF (1 = 1, "Great," "Bad luck") = "Great"

Now suppose that A1 = -3

The first IF tells us that IF (-3> 0,1,0) which is clearly false so the result would be 0.

And now the formula looks like this: IF (0 = 1, "Great," "Bad luck") = "Bad luck"


No comments:

Post a Comment