#
Formulas
Formulas allow you to create calculated properties in Bases using data from other properties. You can perform calculations, manipulate text, work with dates, and more.
#
What formulas can do
Formulas can help you:
- Calculate values, add prices, compute totals, or perform math operations.
- Manipulate text, combine strings, change case, or extract substrings.
- Work with dates, calculate time differences, format dates, or determine deadlines.
- Apply logic, use conditional statements to display different values.
- Process lists, filter, sort, map, or aggregate list data.
#
Create a formula property
To create a formula property:
- In your base, click Properties in the toolbar.
- Click Add formula at the bottom of the menu.
- Enter a name for your formula property.
- Type your formula in the Formula field.
- Close the dialog.
The formula editor will autocomplete function and property names as you type to validate your formula syntax. A green checkmark appears when your formula is valid.
Once created, you can use a formula property like any other property in your base. Add it to views, use it in filters, sort by it, and more.
#
Write a formula
In the formula editor, type an expression using properties, operators, and functions.
#
Reference properties
You can reference different types of properties in your formulas:
- Note properties — Properties from a note's frontmatter.
- File properties — Built-in properties like
file.name,file.size, orfile.mtime. - Formula properties — Other formulas using
formula.formula_name.
Examples:
price * quantity— multiply two note propertiesfile.name + " - " + description— combine file name with a note propertyformula.price_per_unit * 1.1— use another formula property
#
Use operators
Arithmetic operators perform math on numbers:
price + tax— addprice - discount— subtractprice * quantity— multiplyprice / quantity— divide(part / whole) * 100— use parentheses for order of operations
Comparison operators compare values:
price > 100— greater thanage < 18— less thanstatus == "Done"— equalsstatus != "Done"— not equalsfile.mtime > now() - '7d'— compare dates
Boolean operators combine logical conditions:
!completed— notprice > 0 && quantity > 0— andurgent || important— or
Learn more in Bases syntax.
#
Use functions
Functions perform operations on values. The available functions depend on the type of value you're working with. See the complete list of Functions.
Common function categories:
- Global functions —
if(),now(),date(),link(),max(),min() - String functions —
contains(),replace(),split(),lower(),title() - Number functions —
round(),ceil(),floor(),abs(),toFixed() - Date functions —
format(),relative(),date(),time() - List functions —
filter(),map(),sort(),join(),unique()
Examples:
if(price, "$" + price.toFixed(2), "")to define a conditional with number formatting.file.name.lower()to convert to lowercase.tags.contains("urgent")to check if the tags list contains a value.due_date.format("YYYY-MM-DD")to format a date.
#
Formula examples
#
Calculate a deadline
Set a project's due date as 2 weeks after the start date:
start_date + "2w"
#
Display overdue status
Show "Overdue" if the due date has passed and status is not "Done":
if(due_date < now() && status != "Done", "Overdue", "")
#
Format currency
Display a price with 2 decimal places and currency symbol:
if(price, "$" + price.toFixed(2), "")
#
Count list items
Count the number of items in a list property:
tasks.length
#
Calculate priority score
Combine multiple factors into a priority score:
(impact * urgency) / effort
#
Combine text fields
Create a full name from first and last name:
first_name + " " + last_name
#
Calculate total cost
Multiply monthly cost by number of months owned:
monthlyUses * formula.Owned.round()
#
Data types
Formulas work with different types of data:
- Strings — Text enclosed in quotes:
"hello"or'world' - Numbers — Numeric values:
42,3.14,(2 + 2) - Booleans — True or false:
true,false - Dates — Created with
date(),today(), ornow() - Lists — Collections of values:
[1, 2, 3] - Objects — Key-value pairs:
{"name": "value"}
The output type of a formula is determined by the data and functions used.
#
Reference other formulas
Formulas can reference other formulas, creating derived calculations. For example, if you have a formula called price_per_unit:
price / quantity
You can reference it in another formula:
formula.price_per_unit * 1.1
Avoid circular references
A formula cannot reference itself directly or indirectly through other formulas.
See also
This page provides an introduction to Bases syntax in Obsidian.
This page details the functions used in Obsidian Bases to manipulate data from properties in filters and formulas.
Create database-like views of your notes, formatted as tables or cards. Edit, sort, and filter files using their properties.
Map is a type of view you can use in Bases. It requires installing the Maps plugin.
Views allow you to organize the information in a Base in multiple ways. A base can contain several views, and each view can have a unique