ifs

Learn how to use the ifs function in Notion formulas.

New in Formulas 2.0

The ifs() function allows you to write if-then and else-if statements within a Notion formula. When used in its most basic form, ifs behaves in the same way as if, though it is a much simpler alternative to multiple nested ifstatements.

ifs( [condition], ['then' expression], [condition], ['then' expression], [...] ['else' expression] )

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

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 */ }

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 */ )

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" ) )

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 */ )

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 )
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 "🔵" */ "🔵" )

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!" )
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