What Is the IFS Function? Definition and Examples

What is the IFS function? Available in Excel 365, it lets you use multiple consecutive conditions from the IF function. It is generally used to return a desired value based on the condition for each value in data where values in two columns form an array.

Learn about the definition and syntax of the IFS function, along with its advantages and examples in Excel.


IFS Function Definition and Syntax

The IFS function was briefly explained above. Now, let’s review how Microsoft Excel defines it.


Definition

The IFS function checks whether one or more conditions are met and returns the value corresponding to the first TRUE condition. IFS can be used instead of multiple nested IF statements and is easier to read when using multiple conditions.


Syntax

The Excel IFS function syntax is as follows.

= IFS(logical_test1, value_if_true1, [logical_test2, value_if_true2], … [logical_test127, value_if_true127])

  • logical_test1: The condition for returning value_if_true1.
  • value_if_true1: The value returned if logical_test1 is TRUE.
  • logical_test2: The condition for returning value_if_true2. This is an optional argument.
  • value_if_true2: The value returned if logical_test2 is TRUE. This is an optional argument.
  • logical_test127: The condition for returning value_if_true127. This is an optional argument.
  • value_if_true127: The value returned if logical_test127 is TRUE. This is an optional argument.

A condition is a logical expression that must return TRUE or FALSE. If a condition is TRUE, the corresponding value is returned; otherwise, the next condition is evaluated. If all conditions are FALSE, the IFS function returns #N/A.


Advantages of the IFS Function

When comparing multiple conditions and returning different results for each condition, the Excel IFS function has several advantages over the IF function. Here are some of them.

  1. Code readability: Because the IFS function can handle multiple conditions at once, it improves code readability. It is easier to understand than nesting the IF function multiple times.
  2. Processing speed: Because the IFS function handles multiple conditions at once, it is faster than nesting the IF function multiple times.
  3. Number of conditions: The IFS function can handle multiple conditions. Because the IF function handles only one condition, using IFS shortens the code and makes maintenance easier.
  4. Condition complexity: The IFS function can return a different result for each condition. Because the IF function handles only TRUE and FALSE, using IFS allows you to handle more complex conditions.
  5. Validation: While handling multiple conditions, the IFS function can validate input values. For example, it can return an error message when an input value is outside the permitted range.
  6. Expressiveness: While handling multiple conditions, the IFS function can intuitively express the result for each condition. It is more expressive than nesting the IF function multiple times.
  7. Minimized code duplication: Because the IFS function handles multiple conditions at once, it can minimize duplicated code. It shortens the code and makes maintenance easier than nesting the IF function multiple times.
  8. Readability: Because the IFS function handles multiple conditions at once, it makes code more concise and easier to read.
  9. Code maintainability: Because the IFS function handles multiple conditions at once, it makes code more concise and easier to maintain.
  10. Ease of writing code: Because the IFS function handles multiple conditions at once, it makes writing code more convenient. It is easier to write than nesting the IF function multiple times.


IFS Function Example

Suppose there are A, B, and C boxes of different sizes. The boxes get larger from A to C, and their storage costs increase accordingly.

  • A BOX storage cost: 10
  • B BOX storage cost: 20
  • C BOX storage cost: 30


The formula for calculating the storage cost for each box is as follows.

E3 cell =IFS(B3=”A”,10,B3=”B”,20,B3=”C”,30)

IFS function



Conclusion

When comparing multiple conditions and returning different results for each condition, the IFS function has several advantages over the IF function. These advantages include code readability, processing speed, the number and complexity of conditions, validation, and expressiveness. Therefore, the IFS function can be useful when complex condition handling is required.

However, there are a few considerations when using the IFS function. First, the IFS function is available only in Excel 2016 and later. In addition, you must clearly specify the result value for each condition when using IFS. Otherwise, it may return unexpected results. Like the IF function, IFS can also be nested. In that case, code readability decreases, so it is best to use IFS where possible to keep code concise.

Finally, although the IFS function has the advantage of fast processing because it handles multiple conditions, processing speed may decrease as the number of conditions increases. Therefore, when using IFS, it is best to minimize the number of conditions to optimize performance.



Related Excel Functions

Leave a Reply

Your email address will not be published. Required fields are marked *