When you write a formula in a Notion database, you may see the error “Type Mismatch”. This happens because Notion formulas require all values in an operation to be the same data type. For example, you cannot add text to a number or compare a date with a string. This article explains why the type mismatch error occurs in Notion formulas and provides clear steps to fix it. You will learn how to identify the mismatched types and use conversion functions like format(), toNumber(), and dateAdd() to make your formulas work correctly.
Key Takeaways: Fixing the Notion Formula Type Mismatch Error
- format() function: Converts a number, date, or boolean to a text string so you can concatenate it with other text.
- toNumber() function: Converts a text string that looks like a number into an actual number for arithmetic operations.
- dateAdd() and dateSubtract() functions: Work only with date properties and return a date, preventing type mismatch when calculating future or past dates.
Why the “Type Mismatch” Error Occurs in Notion Formulas
Notion formulas use a strict type system. Every value in a formula belongs to one of these types: string (text), number, date, boolean (true/false), or array (list). When you combine two values with an operator or function, both must be the same type. If you try to add a number to a string, Notion raises a “Type Mismatch” error because the operation is undefined.
The root cause is almost always a property that returns a type you did not expect. For example, a Rollup property may return a number, but you treat it as text. Or a Formula property that outputs a date cannot be compared directly with a text string. Notion does not automatically convert types in formulas. You must use explicit conversion functions to change one type to another.
Common Type Mismatch Scenarios
The most frequent mismatches include: adding a number to text with the + operator, comparing a date to a string with > or <, and passing a string to a function that expects a number like round(). Another common case is using an if() statement where the true and false branches return different types. For example, if(prop(“Status”) == “Done”, “Complete”, 0) fails because the first branch returns text and the second returns a number.
Steps to Identify and Fix a Type Mismatch Error
Follow these steps to locate the mismatched types and correct the formula. You will need to inspect each property and use the appropriate conversion function.
- Open the formula editor
In your Notion database, click the column header of the Formula property that shows the error. Then click “Edit formula” from the dropdown menu. The formula editor opens with the current formula displayed. - Identify the data type of each property used
Hover over each property name in the formula. Notion shows a tooltip that includes the property type: Text, Number, Date, Checkbox (boolean), or Rollup. Write down the type for each property. For example, a property named “Quantity” might be a Number, while “Product Code” might be Text. - Check the operator or function that causes the error
Look at the line where the error appears. The error message often highlights the exact position. If you use + between a number and text, that is the mismatch. If you use dateAdd() with a text value instead of a date, that is the mismatch. The operator or function determines what types are allowed. - Apply the correct conversion function
Use one of these functions to change the type of a value:– format(prop(“PropertyName”)) — converts a number, date, or boolean to text. Use this when you need to concatenate a number with text.
– toNumber(prop(“PropertyName”)) — converts a text string that contains digits to a number. Use this when you need to perform arithmetic on a text property.
– date(prop(“PropertyName”)) — converts a text string in a recognized date format to a date. Use this when comparing dates stored as text.
– if() with consistent return types — ensure both branches of an if() statement return the same type. For example, if(prop(“Status”) == “Done”, “Complete”, “Incomplete”) returns text in both cases. - Test the formula with sample data
After making the change, click “Save” in the formula editor. Add a few rows with different property values to verify the formula works for all cases. Check that the output shows the expected type and value. If the error persists, repeat steps 2 through 4.
Common Issues After Fixing the Type Mismatch
Formula returns a blank or empty value after conversion
This usually happens when toNumber() receives a text string that is not a valid number. For example, “ABC” cannot be converted to a number. To avoid this, use if() to check the content before conversion: if(prop(“Code”) != “” and toNumber(prop(“Code”)) != 0, toNumber(prop(“Code”)), 0). This returns 0 for invalid text.
Date comparison still fails after using date()
The date() function only works with text strings that match a specific format like “2024-01-15” or “Jan 15, 2024”. If your text uses a different format, date() returns an empty value. In that case, use parseDate() with the correct format string. For example, parseDate(prop(“Date Text”), “MM/DD/YYYY”) converts a text string in month/day/year format to a date.
Rollup property returns an unexpected type
A Rollup can return a single value or an array depending on the rollup aggregation. If you use a Rollup that returns an array in an operation expecting a single number, you get a type mismatch. To fix this, change the rollup aggregation to “Show original” or use the first() function to extract the first element: first(prop(“Rollup Property”)).
Notion Formula Functions for Type Conversion Compared
| Function | Input Type | Output Type |
|---|---|---|
| format() | Number, Date, Boolean, or Array | Text (string) |
| toNumber() | Text (string) | Number |
| date() | Text (string in standard format) | Date |
| parseDate() | Text (string with custom format) | Date |
| first() | Array | Any type (first element) |
Use format() to convert numbers or dates to text for concatenation. Use toNumber() to convert text digits to numbers for math. Use date() or parseDate() to convert text to dates for date arithmetic. Use first() to extract a single value from a rollup array.
You can now identify and resolve any “Type Mismatch” error in your Notion formulas. Start by checking the data type of each property and applying the correct conversion function. For complex formulas, test each part separately using a temporary formula property. As an advanced tip, use the empty() function to handle missing values before conversion: if(empty(prop(“Quantity”)), 0, toNumber(prop(“Quantity”))). This prevents conversion errors when a property is blank.