How to Use Notion Formula every() and some() for Array Predicate
🔍 WiseChecker

How to Use Notion Formula every() and some() for Array Predicate

Notion formulas let you filter and test data inside a database. The every() and some() functions check whether all or at least one item in an array meets a condition. Without these functions, you would need to write complex nested logic to test multiple values. This article explains how to use every() and some() with array predicates in Notion. You will learn the syntax, how to write predicate functions, and where these formulas work best.

Key Takeaways: every() and some() for Array Predicates

  • every(predicate): Returns true only if every element in the array passes the predicate test.
  • some(predicate): Returns true if at least one element in the array passes the predicate test.
  • Predicate function: A function that takes an array item as its argument and returns a boolean. Example: current > 5.

ADVERTISEMENT

What Are every() and some() in Notion

Notion formulas work inside database properties. The every() and some() functions belong to the array category. They accept two arguments: an array and a predicate function. The predicate function is written inline using the current keyword to refer to the current array element.

The array can come from a rollup, a formula that returns an array, or a multi-select property converted to an array. every() returns true only when every element satisfies the condition. some() returns true when at least one element satisfies the condition. Both functions return a boolean value: true or false.

You need a Notion database with at least one property that produces an array. Common sources are rollups with values, multi-select properties, or formula properties that output lists. Without an array input, every() and some() will return an error.

Steps to Use every() and some() in a Formula

Follow these steps to add a formula property that uses every() or some(). The example checks whether all task priorities in a rollup are above a threshold.

  1. Create a rollup property that returns an array of numbers
    In your database, add a Rollup property. Set the source property to a number column in the related database. Set the rollup aggregation to “Show original” or “Show unique”. This produces an array of values.
  2. Add a Formula property
    Click the + button in the last column of the database. Select “Formula” from the property type list. Name the property something like “All High Priority” or “Any High Priority”.
  3. Write the every() formula
    In the formula editor, type: every(prop("Priority Values"), current > 2). Replace “Priority Values” with your rollup property name. This checks if every priority value is greater than 2.
  4. Write the some() formula
    In a separate formula property, type: some(prop("Priority Values"), current > 2). This returns true if at least one priority value exceeds 2.
  5. Test the formulas with sample data
    Add a few rows in the related database with different priority numbers. Verify that the formula returns the expected boolean values. For every(), all values must pass the test. For some(), only one value needs to pass.

Using every() with Multi-Select Properties

Multi-select properties are not arrays by default. To use them with every() or some(), convert them using the map() function. For example:

every(prop("Tags").map(current), current != "Urgent")

This checks that none of the tags are “Urgent”. The .map(current) converts the multi-select into an array of strings. Then every() applies the predicate to each string.

Using some() with Date Arrays

You can test date arrays from rollups. For example, check if any date in a rollup is past today:

some(prop("Due Dates"), current < now())

This returns true if any due date is earlier than the current date and time. The now() function returns the current timestamp. The predicate compares each date to this timestamp.

ADVERTISEMENT

Common Mistakes and Limitations

Predicate Function Uses Wrong Keyword

The predicate function must use current to refer to the array element. Using prop() inside the predicate will cause an error. For example, every(prop("Numbers"), prop("Numbers") > 5) is invalid. The correct form is every(prop("Numbers"), current > 5).

Array Input Is Not Actually an Array

If the property you pass to every() or some() is a single value, Notion will return an error. Ensure the source property is a rollup set to “Show original” or a formula that outputs an array. A plain number or text property will not work.

Empty Array Returns True for every()

When the array is empty, every() returns true because there are no elements that fail the predicate. This is a logical behavior called vacuous truth. If you need to handle empty arrays differently, add a check: if(empty(prop("Array")), false, every(prop("Array"), current > 5)).

some() with Empty Array Returns False

An empty array causes some() to return false because no element can pass the predicate. This is consistent with standard array logic. If you need a different default, wrap the formula with an if() block as shown above.

every() vs some(): Behavior and Use Cases

Item every() some()
Return value when all elements pass true true
Return value when at least one fails false true if at least one passes
Return value when array is empty true false
Common use case Validate that all items meet a threshold Check if any item meets a condition
Example predicate current >= 10 current < 0

Use every() when you need to enforce a rule across all items. For example, ensure all tasks in a project have a status of “Complete”. Use some() when you only need one item to trigger a condition. For example, flag a project if any task is overdue.

Both functions work with numbers, dates, strings, and booleans. The predicate must return a boolean value. If the predicate returns a non-boolean, Notion will attempt to coerce it. For best results, write predicates that explicitly return true or false.

ADVERTISEMENT