Within a Notion formula, you can use the prop()
function to reference and “pull in” the data from any other property in the same database.
When using prop()
, encapsulate the property name in quotes – e.g. prop("Name")
.
prop("Name")
Code language: JavaScript (javascript)
Notion formulas can work with seven different data-types – string (text content), number, Boolean (checkbox), date, list, person, and page.
All database property types in Notion output a specific data type.
Good to know: Any time this reference states that a function “accepts only numbers as arguments” (or any of the other data types), understand that the function can also accept prop()
as an argument, so long as the referenced property is outputting that data type.
Example: Assume a property called Num is a Number-type property. The max function accepts numbers, so max(5, 10, prop("Num"))
would be valid.
Refer to the following table to see the data type of each property:
Property | Data Type | Notes |
---|---|---|
Title | String | This is the default “Name” property that all database are required to have. |
Text | String | |
Number | Number | |
Select | String | |
Multi-Select | List | Returns a comma-separated string of all values present in the Multi-Select property. |
Status | String | Returns a string even if the Status property is displayed as a Checkbox. |
Date | Date | Use the dateStart and dateEnd functions to access dates in a date range. |
Person | List | Returns a list of Person data types. |
Files & Media | List | Returns a list of string URLs for the assets. |
Checkbox | Boolean | |
URL | String | |
String | ||
Phone | String | |
Formula | StringNumberBooleanDateListPersonPage | Can return any of the data types. |
Relation | List | Returns a list of Page data types. |
Rollup | StringNumberDate | See Notes on Rollups below. |
Create time | Date | |
Created by | Person | Returns a single Person data type. |
Last edited time | Date | |
Last edited by | Person | Returns a single Person data type. |
Example Database
This database contains an example of every property type in Notion referenced within a formula:
Notes on Rollups
Learn more about Rollups in my complete guide to Notion databases.
The data type of a Rollup referenced in a formula depends on both:
- The data type of the property the Rollup is referencing
- The Rollup’s Calculate setting
When a Rollup’s Calculate setting is set to Show Original, it will always output a string value.
This is due to the fact that a Rollup can show the property values for multiple database rows – e.g. a Rollup targeting a number property may show a value of 4, 6, 2
if the current row is related to three other rows.
When Show Original is set:
- A Rollup targeting a number-type property will output a numeric character (e.g.
4
), but it’s still a string. (Use toNumber in your formulas to convert it) - A Rollup targeting a Boolean-type property will output a string value of
Yes
orNo
(use if to perform Boolean comparisons on these) - A Rollup targeting a Date-type property will output a string value representing the date value(s) being rolled up. Even if only one date is shown, the value is still a string (not a date).
When a Calculate setting other than Show Original is chosen, the Rollup will output a different data type:
- If the Rollup is targeting a number or Boolean-type property, all Calculate settings (other than Show Original) will output a number.
- If the Rollup is targeting a date-type property, the Earliest date, Latest date, and Date range settings will output a date. Date range outputs a date object with both a start and end date, allowing you to access either using the start and end functions.
Note that a Rollup cannot access the End Date of a date property, even if one is set. If you need to pull the end date of a date property through a Rollup, you’ll need to first create a formula property that uses the end function to output that end date, then configure your Rollup to target that formula property.
Example Database
Duplicate this example database into your own workspace and try reconfiguring the Rollup property.
Note that changing the settings may require you to click into the Formula property and hit Enter to get it to output data again – even if the Rollup configuration change didn’t cause a Type Mismatch error in your formula.