Notion formulas are powerful, but they have strict limits. One common problem occurs when you write a formula inside a lambda function, such as map() or filter(), and try to reference a relation property directly. The formula returns an error or unexpected results. This happens because lambda functions in Notion formulas cannot access relation properties from the parent row context — only properties of the current item in the iteration are available. This article explains why this limitation exists and provides a reliable workaround to make your formula work.
Key Takeaways: Fixing Relation Property Access Inside Lambda
- Use a rollup property instead of a direct relation: A rollup pre-computes the value you need, making it accessible inside a lambda without scope errors.
- Create a formula property on the related database: Move the calculation logic to the child database, then roll up the result to the parent.
- Apply the lambda on the rollup value, not the relation: Once the value is rolled up,
map()andfilter()work normally because the data is now a simple array or number.
Why Notion Formulas Cannot Access Relation Properties Inside a Lambda
Notion formulas execute in a restricted environment. When you use a lambda function like map(), filter(), or reduce(), the formula engine changes the execution context. Inside the lambda, the current variable refers to each element of the array being iterated, not the row that contains the formula. Relation properties like prop("Related Tasks") belong to the row, not to the iteration variable. Therefore, the formula engine cannot resolve them inside the lambda, producing an error or returning undefined.
For example, suppose you have a database of Projects with a relation to a Tasks database. You want to sum the Hours property of all related tasks. Writing prop("Related Tasks").map(current.prop("Hours")) fails because prop("Hours") is not accessible on the relation array elements directly — those elements are page IDs, not full rows. The formula engine does not allow implicit fetching of related row properties inside lambdas.
The root cause is Notion’s formula scope model. Lambda functions only see the data passed into them, which is a list of page IDs or values. To access a property of a related page, you must first roll up that property to the parent database. A rollup property pre-fetches the values you need, making them available as a plain array, number, or text that the lambda can process.
Steps to Fix Relation Property Access Inside a Lambda
The solution involves two steps: create a formula on the child database (if needed), then create a rollup on the parent database. Finally, use the rollup inside your lambda formula.
Step 1: Ensure the Target Property Exists on the Related Database
- Open the related database
Navigate to the database that is linked via the relation. For example, if your parent database is Projects and the relation points to Tasks, open the Tasks database. - Add or confirm the property you need
Make sure the property you want to use (e.g.,Hours,Status,Due Date) exists as a column in the Tasks database. If you need a computed value, create a formula property in the Tasks database that calculates it. For example, if you needHoursmultiplied by a rate, add a formulaprop("Hours") 50and name itCost. - Save the database
Changes are saved automatically in Notion. You can close the database view.
Step 2: Create a Rollup Property on the Parent Database
- Open the parent database
Go to the database that contains the relation property (e.g., Projects). - Add a new rollup property
Click the + in the last column header. Select Rollup from the property type list. - Configure the rollup
In the rollup configuration panel:
– Relation: Choose the relation property (e.g.,Related Tasks).
– Property: Select the property from the related database (e.g.,HoursorCost).
– Calculate: Choose Show original to get a list of all values. This is required if you plan to usemap()orfilter()inside a lambda. - Name the rollup property
Give it a clear name likeRolled HoursorAll Costs.
Step 3: Write the Lambda Formula Using the Rollup
- Add a formula property
In the parent database, add a new formula property. Name it something likeTotal HoursorFiltered Costs. - Use the rollup property inside the lambda
Now you can write a lambda that operates on the rollup values. For example, to sum all hours:
prop("Rolled Hours").map(current).sum()
Or to filter costs greater than 100:
prop("All Costs").filter(current > 100)
The key is thatprop("Rolled Hours")returns an array of numbers (or text), not page IDs. The lambda can iterate over this array without needing to access relation properties. - Test the formula
Add a few related items with different values. Verify that the formula returns the expected result. If it returns an error, double-check that the rollup calculation is set to Show original and not Show unique or an aggregation.
If the Formula Still Has Issues After the Main Fix
Rollup Returns a Single Value Instead of an Array
If you set the rollup calculation to Sum, Average, Count, or any aggregation, the rollup returns a single number, not a list. Lambdas require a list. Change the calculation to Show original to get an array of all values. Then apply your aggregation inside the lambda formula.
Formula Shows Undefined or NaN
This usually means the rollup property is empty or the related database has no rows. Check that the relation actually links to pages. Also verify that the property you selected in the rollup exists on those pages and contains valid data. If the property is a formula, make sure it returns a number or text, not an error.
Lambda Function Returns an Error About Current
Notion formulas are case-sensitive. Ensure you write current in lowercase. Also confirm that you are using the correct method name: map(), filter(), or reduce(). If you use forEach(), Notion will return an error because forEach() is not supported in formulas.
Direct Relation Access vs Rollup Workaround: Compared
| Item | Direct Relation Inside Lambda | Rollup Workaround |
|---|---|---|
| Scope | Only page IDs — cannot access child properties | Pre-fetched values from the related database |
| Formula syntax | prop("Relation").map(prop("Child Property")) — fails |
prop("Rollup").map(current) — works |
| Setup steps | None — fails immediately | Requires a rollup property on the parent database |
| Performance | No overhead | Rollup updates automatically but may add slight delay on large databases |
| Flexibility | Cannot filter or map based on child properties | Can use filter(), map(), and reduce() on the rolled-up array |
The rollup workaround is the only reliable method to use relation data inside a lambda. It adds one extra property to your parent database but unlocks the full power of Notion’s array functions.
Now you can write formulas that sum, filter, or transform data from related databases using lambda functions. Start by creating a rollup property with Show original as the calculation. If you need to perform calculations on the child data first, add a formula property to the child database and roll up that result. As an advanced tip, you can chain multiple rollups: roll up a formula from the child, then apply a lambda on the parent to compute weighted averages or conditional counts.