# Excel IF Function for Engineering Spreadsheets

Excel has logical functions to help your spreadsheets make decisions. The most common logical function is the IF function. This function can be used to return a result that is dependent on whether an argument is true or false (similar to the AND and OR functions). The syntax is as follows:

IF(logical_test, [value_if_true], [value_if_false])

logical_test: the condition that will be tested

value_if_true: (optional) a value, function or string to return if the logical_test is true

value_if_false: (optional) a value, function or string to return if the logical_test is false

Worksheet 03r contains a simple calculation of tensile stress due to an axial force in a round shaft. The safety factor is then calculated based on the yield strength of the material. An IF function can be used to display a string based on the safety factor in cell C12. If the value is greater than 2, the IF function will return a text string that says the safety factor is acceptable. If it’s less than 2, the function will return a string that says the safety value is not acceptable.

The first argument, logical_test, will be: C12>2. This is the argument that will be tested to see if it’s true or not. If C12 is greater than 2, the function will return the value_if_true argument; if C12 is less than 2, it will return the value_if_false argument. The function will begin with: =IF(C12>2

The value_if_true will be the text string “Safety Factor is Acceptable.” You can simply enter this as your second argument, after a comma, keeping the double quotation marks so Excel recognizes the input as a string.

The last argument, value_if_false, will simply be “Safety Factor is NOT Acceptable.” This tells Excel what to return if the condition is not met. The complete function will be:

=IF(C12>2,”Safety Factor is Acceptable”,”Safety Factor is NOT Acceptable”)

With the default values in the spreadsheet, the safety factor is 7.3, so this function will return the string “Safety Factor is Acceptable.” If you change the inputs, such as increasing the force to 100,000 N, the safety factor will drop below the threshold, and the IF function will return the string “Safety Factor is NOT Acceptable.”

Note the IF function can be used for outputs other than text strings. You can use it to return a number, do a calculation, or perform a function.

Scroll to Top
Complete... 50%