Syntax
IF(logical_expression, value_if_true, [value_if_false])
- logical_expression—The expression to evaluate. Must be true or false.
- value_if_true—The value or formula to return if the logical expression is true.
- value_if_false—[optional]The value or formula to return if the logical expression is false. If omitted, a blank value is returned.
Sample usage
IF([Due Date]1 > [Due Date]2, "Date 1 is Larger", "Date 2 is Larger")
Usage notes
- You can nest IF functions to perform multiple logical evaluations.
- Smartsheet reads the IF statements in the formula from left to right, displaying a value based on the first expression to evaluate it as true. When nesting IF functions, the optional return_if_false will be returned only if all logical expressions are evaluated as false.
Examples
This example references the following sheet information:
Row # | Item Number | Status (Symbols column type) | Order Date | In Stock?(Checkbox column type) |
---|---|---|---|---|
Row # 1 | Item Number C001 | Status (Symbols column type) Green | Order Date 12/15/24 | In Stock?(Checkbox column type) true |
Row # 2 | Item Number C002 | Status (Symbols column type) Red | Order Date 12/12/24 | In Stock?(Checkbox column type) false |
Row # 3 | Item Number C003 | Status (Symbols column type) Yellow | Order Date 12/15/25 | In Stock?(Checkbox column type) true |
Row # 4 | Item Number C004 | Status (Symbols column type) Green | Order Date 12/20/24 | In Stock?(Checkbox column type) true |
Given the table above, here are some examples of using an IF() function in a sheet:
Formula | Description | Result |
---|---|---|
Formula =IF([Status]1 = "Red", "At Risk", "On Time") | Description IF the "Status" column row 1 equals “Red”, return the value "At Risk”, if not return the value “On Time”. | Result On Time |
Formula =IF([Order Date]2 < TODAY(), "Red", IF([Order Date]2 > TODAY(), "Yellow", IF([Order Date]2 = TODAY(), "Green"))) | Description IF the “Order Date” column row 2 is less than TODAY, return a “Red” value. IF the “Order Date” column row 2 is greater than TODAY return a “Yellow” value. IF the “Order Date” column row 2 equals TODAY return a “Green” value. | Result Red |
Formula =IF([Order Date]3 < TODAY(), "Red", IF(AND([Order Date]3 >= TODAY(), [Order Date]3 < TODAY(+7)), "Yellow", "Green")) | Description IF the “Order Date” column row 3 is less than TODAY return a “Red” value. IF the “Order Date” column row 2 is greater than or equal to TODAY, AND less than the next 7 days, return a “Yellow” value. If neither applies return the value “Green”. | Result Green |
Formula =IF(COUNTIF([Item Number]:[Item Number], [Item Number]@row) > 1, 1, 0) | Description Search for duplicates in a checkbox column type: IF the "Item Number" column has more than one instance of the current row's Item Number, then check a checkbox on this row. Otherwise, if there are no duplicates, do not check the checkbox. | Result No rows checked |
Still need help?
Use the Formula Handbook template to find more support resources and view 100+ formulas, including a glossary of every function that you can practice working with in real time, and examples of commonly used and advanced formulas.
Find examples of how other Smartsheet customers use this function or ask about your specific use case in the Smartsheet online Community.