Sunday 21 June 2015

The If Function Excel

The If Function Excel


you may have been issued with a excel function dictionary with one hundred and fifty functions


Our new online version contains almost 500 functions described with examples make this the first place to go get help for excel

http://www.exceltraining-london.co.uk/excelFunctions/ExcelLondon/excelfunctiondictionary.html

other information can be found by clicking on the icons at the bottom of the page.

Here's an example of what you may find. we call this the Vulcan function for all you trekie fans "it's logic captain"

Basic Description

The Excel IF function tests a user-defined condition and returns one result if the condition is true, and another result if the condition is false.
The syntax of the function is :
IF( logical_test, value_if_true, value_if_false )
where the arguments are as follows:
logical_test-The user-defined condition that is to be tested and evaluated as either TRUE or FALSE
value_if_true-The result that is to be returned from the function if the supplied logical_test evaluates to TRUE
value_if_false-The result that is to be returned from the function if the supplied logical_test evaluates to FALSE

Nesting the Excel If Function

The If function is frequently 'nested' in Excel. I.e. the value_if_true or the value_if_false argument is replaced with another call to the If function (see Example 3 below).
Excel 2003 allows up to 7 levels of nested If functions, but Excel 2007 and Excel 2010 allow up to 64 levels of nesting. For Example, the following formula (which has 8 levels of nesting), will result in an error in Excel 2003 but will work correctly in Excel 2007 or Excel 2010 :
=IF(A1=1,"red", IF(A1=2,"blue", IF(A1=3,"green", IF(A1=4,"brown",
IF(A1=5,"purple", IF(A1=6,"orange", IF(A1=7,"yellow",
IF(A1=8,"grey", IF(A1=9,"pink", "black" ) ) ) ) ) ) ) ) )



If you do find yourself using multiple levels of nesting, you should probably consider other Excel functions that can be used to obtain the same result more succinctly. For example, the above function could be made much simpler by using the Excel Choose function.

Excel If Function Examples

If Function Example 1

The following example shows the Excel If function applied to two sets of numbers. In this example, the logical_test checks whether the corresponding value in column B is equal to 0, and the function returns :
  • The text string "div by zero" if the value in column B is equal to 0
or
  • The value in column A divided by the value in column B if the value in column B is not equal to zero
 ABCD
154=IF( B1=0, "div by zero", A1/B1 ) - returns the value 1.25
250=IF( B2=0, "div by zero", A2/B2 ) - returns the text string "div by zero"

No comments:

Post a Comment