In Notion, you can use the formula feature to automatically change task icons based on their status. This not only enhances the visual appeal of your workspace but also helps you manage tasks more clearly. For scenarios involving multiple conditions, I recommend using the ifs
function as itโs more concise and easier to adjust compared to nested if
functions. Of course, if you're interested in learning how to use nested if
functions, click here for a practical guide.
Hereโs a step-by-step guide:
1. Ensure the Column is a Formula
First, make sure the column you're working with is set to Formula. If you havenโt created one yet, click the +
button at the bottom of your table and select Formula.
2. Edit the Formula
Click on any blank space under the formula column, or click Edit formula to open the formula editor.
3. Type the ifs
Function
Type ifs
in the editor and select it from the dropdown menu.
4. Choose the Condition Column
Next, choose the column that you want to use as the condition, such as Status, Stock, or others. Pick the column that best suits your needs.
5. Write the Formula Logic
Now, write the formula according to your requirements. For example, if you want the status "Completed" to display a green circle ๐ข and "In Progress" to display an orange circle ๐ , your formula would look like this:
ifs(Status == "Completed", "๐ข", Status == "In Progress", "๐ ", true, "Unknown")
In this formula, ifs
checks the status and returns the appropriate icon. A few things to keep in mind:
- Each condition is followed by the icon you want to display (e.g., ๐ข or ๐ ).
- The last
true
condition ensures that if none of the previous conditions are met, it returns a default value. In this example, the default value is "Unknown," but you can customize this to whatever you prefer.
6. Save and Apply
Once you've finished writing the formula, click Save. Any future changes or additions to the status will automatically update the icons according to the new formula.
The Difference Between if
and ifs
Both if
and ifs
in Notion formulas allow you to return different results based on conditions, but there are key differences:
if
Function:- Syntax:
if(condition, result1, result2)
- Use Case: Best used when you only need to check a single condition. It evaluates one condition and returns the first result if true, or the second result if false.
Example: If the status is "Completed," return a green circle; otherwise, return a red circle:
if(Status == "Completed", "๐ข", "๐ด")
- Syntax:
ifs
Function:- Syntax:
ifs(condition1, result1, condition2, result2, ..., true, default)
- Use Case: Ideal when you have multiple conditions to check. It evaluates each condition sequentially and returns the corresponding result. If none match, the
true
condition acts as a fallback, returning a custom default value. Example: Return different icons based on the status:
ifs(Status == "Completed", "๐ข", Status == "In Progress", "๐ ", true, "โ")
- Syntax:
When to Use if
or ifs
?
- Use
if
: If you only need to check one condition, or you're concerned with a specific condition,if
is the simplest and most direct choice. - Use
ifs
: If you need to check multiple conditions,ifs
keeps your formula clean and avoids complex nestedif
statements.