20 excel functions to know and use before you die – the if function 280611

13
20 Excel Functions to Know and Use Before you Die – The IF Function

description

Continuing our series of “20 Functions to Know and Use before You Die”, this time it is the turn of the IF function. Chances are, that in virtually any half decent spreadsheet you open there will be an IF statement. They can vary from a basic test returning a TRUE or FALSE outcome, multiple nested statements through to highly complex array formulas.

Transcript of 20 excel functions to know and use before you die – the if function 280611

Page 1: 20 excel functions to know and use before you die – the if function 280611

20 Excel Functions to Know and Use Before you Die – The IF Function

Page 2: 20 excel functions to know and use before you die – the if function 280611

Continuing our series of “20 Functions to Know and Use before You Die”, this time it is the turn of the IF function.

Chances are, that in virtually any half decent spreadsheet you open there will be an IF statement. They can vary from a basic test

returning a TRUE or FALSE outcome, multiple nested statements through to highly complex array formulas.

Page 3: 20 excel functions to know and use before you die – the if function 280611

One thing they all have in common is that they give you a TRUE or FALSE answer and based on that you can then perform calculations

or display a text message.The basic structure of the IF function is;

=IF(test, do if TRUE, do if FALSE)

Page 4: 20 excel functions to know and use before you die – the if function 280611

The test part of the function might be to check a value in a cell or to compare various cells e.g. A3 > 200, D5=G5, F2 = “text” etc.

If the outcome of the test is TRUE, it then performs the ‘do if TRUE’ part or if the test gives a FALSE outcome it performs the ‘do if FALSE’ part. Note that the FALSE section is optional but if the

outcome is FALSE, Excel will display the word ‘FALSE’ in the cell.

Page 5: 20 excel functions to know and use before you die – the if function 280611

If we wanted to display the words “Chase customer” if the word “No” appears in column F, our formula would be;

=IF(F2=“No”,“Chase customer”,“Paid”)

Test: has the cell to the left got the word “No” in it?

Do if TRUE: display the words “Chase customer”

Do if FALSE: display the word “Paid”

Note: if you want to display text you must have double speech marks.

Page 6: 20 excel functions to know and use before you die – the if function 280611

If you don’t want to display anything, simply enter “” with no space between the speech marks.

The IF statement can then be extended to test multiple cells using AND , OR or NOT.

Page 7: 20 excel functions to know and use before you die – the if function 280611

If we were particularly concerned about late payments on desks and wanted to focus on those our formula might be;

=IF(AND(F2=“No”,E2=“Desks”), “Chase customer”,“Not urgent”)

Page 8: 20 excel functions to know and use before you die – the if function 280611

You can also create sets of nested IF statements. You can create up to 7 nested statements to perform multiple subsequent tests.

Take the data below. I want to see if the Sales value falls between my Min and Max values above the table.

In order to test this we would need the following formula;

=If($D5>=F$1,IF(($D5<=F$2,$D5,NA()),NA())

Page 9: 20 excel functions to know and use before you die – the if function 280611

The first IF tests whether the sales value (240) is greater than the Min value (100), which is TRUE. It then performs the TRUE portion

of the statement which in this case is another IF. This time it tests whether 240 is less than or equal to the Max value (149). This is

FALSE, so displays NA(). When the test for both is TRUE, it simply displays the Sales value.

Page 10: 20 excel functions to know and use before you die – the if function 280611

Beyond nested Ifs you are then looking at array formulas, which are a special type of formula that allow you to perform multiple tests on

whole ranges of data with a single formula.

Page 11: 20 excel functions to know and use before you die – the if function 280611

Returning to our original data table, I might want to find out total sales on desks or cabinets in both South and West regions. In Excel 2007 and 2010 there are some new functions such as SUMIFS and

AVERAGEIFS that allow you to perform multiple criteria SUMIF type calculations but you can do this and other far more complex

calculations with an array formula;

{=SUM(IF(((D2:D50=“South”)+( D2:D50=“West”))*((E2:E50= “Cabinets”)+(E2:E50= “Desks”)),D2:D50))}

Note that * and + replace AND and OR in this type of formula.

Page 12: 20 excel functions to know and use before you die – the if function 280611

So next time, have a go at adding an IF statement into your worksheets. You’ll wonder how you ever worked with data without

an IF.

Next time in this series……VLOOKUP.

Page 13: 20 excel functions to know and use before you die – the if function 280611

  Find out more about Excel courses and tips.

Find out more on Bespoke Training and Managed Training Services on Thales Training and Consultancy