empty

Learn how to use the empty function in Notion formulas.

This article may contain affiliate links.This article may contain affiliate links.

The empty() function returns true if its argument is empty, or has a value that equates to empty – including 0, false, "", and [].

In truth, empty() is a function that checks for falsiness, not true emptiness.

empty(string)
empty(number)
empty(boolean)
empty(date)
empty(list)

string.empty()
number.empty()
boolean.empty()
date.empty()
list.empty()
Code language: JavaScript (javascript)

However, you can use empty() to check for actual emptiness using an equality comparison:

string == empty()
number == empty()
boolean == empty() /* Will never be true */
date == empty()
list == empty() /* Will never be true; check length instead */
Code language: JavaScript (javascript)

empty() accepts all data types, including strings, numbers, Booleans, and dates.

empty() also has a second ability: If you use empty() as the return value in a formula (without any arguments), it returns a truly empty value.

Copy link to heading

By default, empty() checks for falsiness, and there are four possible falsy values in a Notion database property:

  1. True emptiness
  2. false (Boolean value)
  3. 0
  4. "" (a blank String)
  5. [] (a blank list)

However, you can also use empty() without any arguments as a return value that represents actual emptiness.

Therefore, you can do an equality check between any other value and empty() to see if the other value is truly empty.

For example, let’s assume a Number property contains 0 for a particular page:

prop("Number").empty() /* Output: True */

prop("Number") == empty() /* Output: False */
Code language: JavaScript (javascript)
A screenshot showing how to check for true emptiness.

Simply calling empty() on the Number property checks for falsiness, which may not always be what you want. By actually checking for equality against empty(), you’re checking for true emptiness.

There are some quirks around different data types you’ll want to be aware of when using this technique:

Property TypeNotes
String"" is not considered empty. Only Text and Title properties that are truly empty are considered empty.
Number
BooleanCan never be empty. Booleans are only ever true or false.
Date
ListLists are never considered empty. [] is not empty, and neither is a blank Multi-Select property. Check for length == 0 instead.
Copy link to heading

In addition to helping you check for actual emptiness (as detailed above), using empty() on its own will let you return an actual “empty” value from a formula:

empty() /* Output: empty (e.g. no output) */
Code language: JavaScript (javascript)

This can be very useful when you want to make sure a formula doesn’t try to return a non-empty value if its required inputs are empty.

For example:

if(
  prop("Number") == empty(),
  empty(),
  today()
)
Code language: JavaScript (javascript)

This formula still has a return type of Date. If you replaced empty() with something like "", you’d get a return type of Unknown for the formula.

Essentially, this ability means you no longer have to do awkward tricks like "".parseDate() to create an empty() case within a formula that returns a date.

Copy link to heading
empty("") /* Output: true */

0.empty() /* Output: true */

empty(false) /* Output: true */

[].empty() /* Output: true */

empty([""]) /* Output: false */

/* Assume a row where the Name property is currently blank */
prop("Name").empty() /* Output: true */
Code language: JavaScript (javascript)

empty() can be preceded by the not operator to ensure that a property or value is not empty:

/* Assume a row where the Name property contains text */
not empty(prop("Name")) /* Output: true */

!prop("Title").empty() /* Output: true */

/* The same result can be accomplished with conditional operators (Assume the Name property contains text in this row) */
empty(prop("Name")) ? false : true /* Output: true */
Code language: JavaScript (javascript)
Copy link to heading

The example database below shows how you can sort sub-tasks by their parent task’s due date. This pictured view is simplified for ease-of-use; view the database’s All Properties tab to see every property at work.

Copy link to heading
Notion – The all-in-one workspace for your notes, tasks, wikis, and databases.
A new tool that blends your everyday work apps into one. It’s the all-in-one workspace for you and your team
thomasfrank.notion.site
Copy link to heading
if(
    not empty(
        prop("Parent Task")
    ),
    prop("Parent Due Rollup"),
    if(
        empty(
            prop("Sub-Tasks")
        ),
        prop("Due"),
        if(
            not empty(
                prop("Due")
            ),
            prop("Due"),
            dateAdd(
                now(),
                100,
                "years"
            )
        )
    )
)
Code language: JavaScript (javascript)

This formula uses both empty() and not empty() in conjunction with multiple nested if statements in order to determine a Parent Due Date.

The entire database view is then sorted by:

  1. Parent Due Date
  2. Parent Task Name
  3. Due Date

Notice that the formula also calls in a Parent Due Rollup property, which is actually configured to pull in the Parent Due Date content of the Parent Task:

That’s right – this is a formula, which pulls in its own output (from other database rows)!

Let’s work through what this formula is doing:

  1. First, it checks if Parent Task is not empty. If so, we know we’re dealing with a sub-task, so we output the value of Parent Due Rollup. Note that Parent Due Rollup’s content is determined by the rest of the logic in this formula.
  2. If Parent Task is empty, then we check if Sub-Tasks is empty as well. If so, we’re dealing with a “lone” task – it’s not a parent task nor a sub-task. In this case, we output its Due date value.
  3. If Sub-Tasks is not empty, then we know we’re dealing with a parent task. Next, we check if its Due property is not empty.
  4. If it does have a date, we output that. If not, we output a standard date of now plus 100 years (using dateAdd). This ensures that parent tasks with no actual due date have a hidden “default” date, enabling sub-tasks to still be sorted underneath them as intended.

Other formula components used in this example:

if – Thomas Frank
thomasjfrank.com
now – Thomas Frank
thomasjfrank.com
dateAdd – Thomas Frank
thomasjfrank.com
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