ifs

Learn how to use the ifs function in Notion formulas.

The ifs() function allows you to write if..else if…else statements in a Notion formula.

Just like if, it allows you to create conditional statements. However, it allows for more than two conditions. When using if(), you have to nest multiple instances of if() to get the same result.

ifs(
    [condition], 
    ['then' expression], 
    [condition],
    ['then' expression],
    [...]
    ['else' expression]
)
Code language: JavaScript (javascript)

If-then statements, also called conditional statements, contain:

  • The condition – a statement to be evaluated for truthiness (i.e. “is it true?”)
  • The “then” statement – a statement that is executed if the condition is true
  • The “else” statement – a statement that is executed if the condition is false

With ifs(), you can have any number of condition and then statements (as long as you have one of each). Each condition/then statement pair past the first one can be considered an “else-if” statement.

Previously, Notion did not support the else-if statement that is available in more popular scripting and programming languages, such as Javascript.

With an else-if statement, you could write code like this (in Javascript):

/* This is Javascript code that won't work in a Notion formula */

if (x < 13) {
    /* Do one thing */
} else if (x < 19) {
    /* Do another thing */
} else {
    /* Do the last thing */
}
Code language: JavaScript (javascript)

The ifs() function allows you to write these else-if statements in a Notion formula, instead of relying on nested ifstatements.

ifs(
    [condition], 
    ['then' expression], /* Do one thing */
    [condition], 
    ['then' expression], /* Do another thing */
    ['else' expression]  /* Do the last thing */
)
Code language: JavaScript (javascript)

In Formulas 1.0, you would have to instead create nested if-then statements, like so:

if(
    prop("Age") < 13,
    "Child",
    if(
        prop("Age") < 19,
        "Teenager",
        "Adult"
    )
)
Code language: JavaScript (javascript)

But now with the introduction of the ifs function, the above is much easier.

ifs(
    prop("Age") < 13,
    "Child", /* Do one thing */
    prop("Age") < 19,
    "Teenager", /* Do another thing */
    "Adult" /* Do the last thing */
)
Code language: JavaScript (javascript)

This formula compares the output of a Select property called Type (which has a data type of String) with the string value “Mammal”. If the two are equal, it outputs true; otherwise, false.

ifs(
    prop("Type") == "Mammal",
    true,
    false
)
Code language: JavaScript (javascript)
ifs(

    /* Check if Done is checked, and if so display "😀" */
    prop("Done"),
    "😀",

    /* Otherwise check if Due is empty, and if so display "⚪" */
    not prop("Due"),
    "⚪", 

    /* Otherwise, check if Due is the same as the current date, 
    and if so display "🟢" */
    formatDate(prop("Due"), "L") == formatDate(now(), "L"),
    "🟢",

    /* Otherwise, check if the current date is past Due,
    and if so display "🔴" */
    prop("Due") < now(), 
    "🔴", 

    /* Otherwise, display "🔵" */
    "🔵" 

)
Code language: JavaScript (javascript)

You can also use ifs to simply return a value if the first condition is true, with no need to add the “else” expression — this will be blank by default.

ifs(

    /* Check if the current date is past Due Date */
    now() > prop("Due Date"),

    /* If it is, display this. Otherwise, display nothing. */
    "This is overdue!" 

)
Code language: JavaScript (javascript)
About the Author

My name is Thomas Frank, and I'm a Notion-certified writer, YouTuber, and template creator. I've been using Notion since 2018 to organize my personal life and to run my business and YouTube channel. In addition to this formula reference, I've created a free Notion course for beginners and several productivity-focused Notion templates. If you'd like to connect, follow me on Twitter.

🤔 Have an UB Question?

Fill out the form below and I’ll answer as soon as I can! ~Thomas

🤔 Have a Question?

Fill out the form below and I’ll answer as soon as I can! ~Thomas