# IF statement

By Haydn Pallister | August 13, 2020

### Overview

This is an extract from our pre-course videos for our renewable energy and infrastructure project finance modeling course.

### Video

IF statement | Pivotal180

Video Transcript

The IF function is one of if not the most widely used functions in financial modeling. In this lesson we’re going to learn how to write an IF statement as an example. You may wish to check if we spent the exact amount over a year that we targeted to spend. You can imagine that isn’t an uncommon question to ask and I ask myself this every week with my own budget. So in this example, we have a target span of \$8 million in the year in cell B2. However, we spent \$7 million shown in cell A2, much less than we targeted. Here, we can use an IF statement to do this with a calculation rather than just eyeballing the result. If we were checking many results in a model over many years or many columns, eyeballing is clearly not easy or reasonable. So we can build an IF function. The IF function is constructed as =IF(logical_test, [value_if_true], [value_if_false]).

Okay.

The logical test is what Excel is looking for and checking. In our case being, does the actual span equal our target span? And we can then define a value if that is true, and a value if that is false. So with our example, we would write: IF(A2=B2 ,1, that’s the value if it’s true, 0, the value of it’s false). And A2 doesn’t equal B2, so this logical test yields false and the value of false, or 0, is the output. It’s as simple as that. And we will do this many times throughout the course.