Once you've got the hang of the basics in Excel you'll normally require the use of the IF function to carry out slightly more complex actions.
At first glance, the IF function can appear a little daunting but after some time it'll become second nature and enable you to create spreadsheets that will begin to deliver significant benefits.
The IF function usually incorporates 3 elements (arguments), the logical_test, the value_if_true and the value_if_false. You'll notice from the square brackets below that the last two arguments are optional. If you are new to the IF function I would recommend supplying all 3 arguments to help understand what the formula is doing.
logical_test
This part of the formula, is usually a comparison, the simplest form is A1 = B1 where A1 and B1 are 'tested' to see if they match. The output of this test is one of two possibilities, true or false. Some other logical tests could be A1 > B1, A1 = "apples" or even A1 = B1 = C1. The logical test element can expand to become considerably more complexvalue_if_true
This part of the formula is the output when the logical test is true, for example, if the desired response when A1=B1 is to output 1, the formula would begin =if(A1=B1,1...
value_if_false
Similarly, this part of the formula is the output when the logical test is false. Expanding on the previous example, if the desired response when A does not equal B is 0 then the completed formula would be =if(A1=B1, 1,0)
Note - Remember that when using text in formulas it needs to be contained within the " character for the Excel to recognise it as text and not a reference. This is not required for numbers as you'll see in the following example.
Example
Practical example
Here we're going to create a formula to test the contents of a cell to see if it matches the text "This".
This will now test the contents of cell B2 to see if it matches "This" if it does match (true) the desired response is a 1. If it does not match (false) the desired response is a 0.
Here you can see the output of the formula in cell C2 is a 1 because B2="This"
When the formula is filled down to the next cell, the test is applied to the subsequent cell, C3 which does not contain the text "This" so the result of the test will be False and the response from the formula will be a 0
Comments
Post a Comment