The use of the IF function with numeric values is based on using different comparison operators to express your conditions. Excel IF statement for numbers: greater than, less than, equal to
Now that you are familiar with the IF function's syntax, let's look at some formula examples and learn how to use it in real-life scenarios. Using the IF function in Excel - formula examples The formula compares the values in cells A1 and B1, and if A1 is not equal to B1, the formula returns the sum of values in cells A1:D1, an empty string otherwise. The formula compares the values in cells A1 and B1, and if A1 is greater than B1, it multiplies the value in cell C3 by 10, by 5 otherwise. Here are just a couple of formula examples: You do this by using arithmetic operators or other functions in the value_if_true and /or value_if_false arguments.
Instead of returning certain values, you can get your IF formula to test the specified condition, perform a corresponding math operation and return a value based on the result.
Technically, in this case the formula returns an empty string, which is invisible to the user but perceivable to other functions. In case you don't want your Excel IF statement to display any value when the condition is met, enter double quotes ("") in the second parameter, like this: =IF(B1>10, "", "Bad"). there is only a comma following logical_test), the IF function returns zero (0) when the condition is met. If the value_if_true argument is omitted (i.e. Though the last two parameters of the IF function are optional, your formula may produce unexpected results if you don't know the underlying logic beneath the hood. if the condition is not met.įor example, if you add "Bad" as the third parameter to the above formula, it will return the text " Good" if a value in cell B1 is greater than 10, otherwise, it will return " Bad":
value_if_false (optional) - the value to be returned if the logical test evaluates to FALSE, i.e.if the condition is met.įor example, the following formula will return the text "Good" if a value in cell B1 is greater than 10: =IF(B1>10, "Good") value_if_true (optional) - the value to return when the logical test evaluates to TRUE, i.e.In this argument, you can specify a text value, date, number, or any comparison operator.įor example, your logical test can be expressed as or B1="sold", B110. logical_test (required) - a value or logical expression that can be either TRUE or FALSE.
IF(logical_test,, )Īs you see, the IF function has 3 arguments, but only the first one is obligatory, the other two are optional.