These are NOT part of the AAT synoptic, but I deem them sufficiently useful that it warrants going over them – particularly how to hide an error message. However, if you only want to learn what you need for the exam and no more, then click here to continue.
If you’re curious, then please, dear reader, come follow… caution: mind-altering formulae ahead!
Hiding error messages with IFERROR
This is a fantastically useful function. I use it a lot for spreadsheets I’m designing for others to use. Basically, it hides error messages (anything that starts #, like #N/A or #DIV/0!) so your users don’t get freaked out – and of course there’s always the thing that it looks kind of neater too.
Consider this example here, where having entered a name which isn’t on the list, my VLOOKUP has returned a #N/A in cell B2. It would be very useful to be able to say something like ‘no-one of that name’ or even not show anything at all.
What we need to do is use the IFERROR function. Let’s have a look at it.
=IFERROR ( value , value_if_error )
It seems simple enough – only two arguments – but it can confuse people a little bit. What it’s saying is If that’s an error, do this instead. We can work through it like this: The first argument, value, is the formula that’s generating the error. That’s right, the formula in its entirety is going to be our first argument. The second argument, value_if_error, is what we want to happen if indeed there is an error – have a useful message or maybe not show anything at all.
That will mean my function will look like:
=IFERROR ( VLOOKUP(B1,A5:B9,2,0) ,“no-one of that name” )
Now I needn’t worry about the #N/A as it’s all taken care of.
The IS functions
There are nine functions in the IS group, and they all return TRUE or FALSE. They are most commonly used to check for errors in data entry or as the result of formulae. For instance, if cell A1 appeared to have a numeric value in it, you could check by saying =ISNUMBER(A1). If A1 is a number, it would return TRUE. If it wasn’t, it would return FALSE.
You can harness these by having them as your first argument in an IF statement. Supposing you want to multiply cell B2 by the VAT rate, 20%. However, that’s going to fail if someone puts a text value in B2, instead of a numeric value. So, we could say:
=IF ( ISNUMBER (B2) , B2*20% , “please enter a number“)
If it’s true that B2 is numeric then multiply it by 20%, otherwise display the text “please enter a number”.
– ISERROR tests for an error – any error.
– ISERR tests for any error but #N/A.
AND and OR
Here are a couple of functions which can totally blow your IF statement wide open. These two functions are really simple and hugely widen the scope of an IF.
- AND looks at various conditions and if ALL are true, returns TRUE. If just a single condition is not true, it returns FALSE.
In the example below, all my conditions are that the three values are above 30. All of them are; so we have an answer of TRUE.
In this example, one of my conditions is now below 30. This causes AND to return FALSE.
- OR looks at various conditions and if just ONE is true, returns TRUE. If no conditions are true, it returns FALSE.
In the example below, my conditions are that the three values are above 30. Even though one of them isn’t, it doesn’t matter – at least one of them is so we have an answer of TRUE.
In this example, none of my conditions is now above 30. This causes OR to return FALSE.
- How do we use these? We nest them as the first argument of an IF (logical_test). As an example, supposing in a qualification you only get a certificate if you pass five exams, not just one? We would need an AND in order to test that all cells concerned have values above 70.
In the first example here, our candidate failed Exam 5, so doesn’t get a certificate:
Our second candidate has passed all five, so we can award them their certificate.
Note how the whole of the logical_test is the AND function:
Exciting formula ahead!
So… you’re wondering what you’d do if you had to go off the Result, not the Score? This calls for a bit of a stop-and-think…. I need to check:
- that C2 says either “distinction, “merit” or “pass” AND
- that C3 says either “distinction, “merit” or “pass” AND
- that C4 says either “distinction, “merit” or “pass” AND
- C5 AND C6 etc….
so I need ORs and an AND. And I need my ORs inside – nested in – my AND. Check this out. This is fun!
=IF(AND(OR(C2="distinction",C2="merit",C2="pass"),OR(C3="distinction",C3="merit",C3="pass"),OR(C4="distinction",C4="merit",C4="pass"),OR(C5="distinction",C5="merit",C5="pass"),OR(C6="distinction",C6="merit",C6="pass")),"Award certificate","no certificate")
Break it down. Look at it carefully. Count the open and close brackets – a pair each for each OR, a pair for the AND, a pair for the IF. Count the commas – one to separate each OR in the AND, one to separate the AND from the other two arguments of the IF. I’m certain you’ll find that if you’re really careful, you actually can follow the logic of what’s going on. I’ve coloured the different arguments here so you can see more easily what’s happening.
Wow, right? How cool is that? And it’s *mind-blowing* that you can work your way through it and create something like this yourself!
It really is a case of looking at what’s going on with a critical, careful eye and working your way logically through the symbols. After all, at this point, you know that any time you see Word( you know you’re looking at a function. You can have a look at the Help files in Excel and understand a lot more of what it’s explaining about that function – you know what syntax, arguments, cells, values, ranges and so on are. You understand the $ and the “double quotes”. There are only a couple of other symbols you should learn (covered in this post) and you can genuinely look at anything anyone has created and work out what’s going on.
I appreciate I went way off-piste on this, in terms of what you need for the synoptic, but I hope you now appreciate why I wanted to go through this. The power of all these functions combined is truly, truly staggering – and you have the key to it all. Enjoy!
Have a play
Please feel free to download some exercises here – lots of worksheets for you to get your teeth into. If you’re feeling brave, recreate the nested IF/AND/OR above!
If you’re following the suggested Learning Plan, please click here to go to the next post.