Getting started with IF statements

An introductory guide to the IF Function
formula Friday

Formula Friday #13

Formula Fridays are short reads, spotlighting a single formula that you can start using straight away.

Today we will cover the basics of IF statements

There is a lot that can be done with the IF function. A LOT.

From a simple statement of ‘if x is greater than y, put true. If not, put false’. 

To something a little more elevated such as ‘if x is greater than y, look to a different data set to find the relevant classification. If not, put false’.

And onto the super complex of, ‘if x is greater than y, and y is less than z, put true. If not look for the classification of z’. 

If I have lost you, don’t worry we will cover all of these in their own time. This post is just going to focus on the basics of an IF statement.

The IF Function

It’s like our brain in Excel form.

The first thing you have to do is input the logical test. This is where those mathematical signs you learnt at school come into play. You know the ones ‘<’ less than, ‘>’ greater than, and ‘=’ equal to – I always pronounce this equals to, don’t ask me way.

If you want to get fancy, greater than or equal to is ‘>=’, less than or equal to is ‘<=’ and not equal to is ‘<>’.

Next you need to decide what to do if the logical test is true, and what to do if the logical test is not true, as known as false.

An example formula would look like this

=IF(10>5,”Y“,”N“)

Ready to take your data analysis to the next level?

Get in touch today.

Like this post? You should see my newsletter.

Subscribe to the Excel & ME newsletter to get updates that will empower you to inform your business decisions with data.

Let’s take it up a notch

You can replace any element of an IF statement with another Function or formula. 

So instead of saying IF 10 is greater than 5. You could say if the result of this VLOOKUP is greater than 5. That formula would look like this:

=IF(VLOOKUP(A2,A8:B15,2,0)>5,”Y“,”N“)

Any text inputs need to be within quotation marks, as with other functions, or the formula will result in an error.

The result if true and the result if false doesn’t have to be a text input. They can also be formulas. 

=IF(VLOOKUP(A2,A8:B15,2,0)>5,VLOOKUP(A2,C8:D15,2,0)*10,VLOOKUP(A2,C8:D15,2,0)/10)

It all depends on what you want the outcome to be.

You can string multiple IF statements together. This is something called a nested if. But we will cover that in a different post as it takes quite a lot of brain power to get your head around.

Until next time

Ax

Related Articles from Excel & ME

How to use find function blog post feature image

Intro to the FIND Function

An introductory guide to the FIND function
Understanding excel error messages blog post feature image

How to decode Excel error messages

A guide for decoding formula error messages in Excel
Improve margin forecasting with goal seek blog post feature image

Using Goal Seek to Forecast OTB Margin

How to use index with match function in excel blog post feature image

How to INDEX MATCH MATCH

This is a step-by-step guide for how to INDEX, MATCH, MATCH in Excel
Using array constrains with countif function blog post feature image

How to use array constraints with the COUNTIFS Function

An advanced guide to using COUNTIFS to get more from your data
How to use subtotal function blog post feature image

Adding Subtotals to your data

A step-by-step guide to adding subtotals to your data summaries