Formulas - Obsidian Help

Formulas

permalink: formulas
description: Formulas allow you to create calculated properties using data from other properties. You can perform calculations, manipulate text, work with dates, and more.

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:

Create a formula property

To create a formula property:

  1. In your base, click Properties in the toolbar.
  2. Click Add formula at the bottom of the menu.
  3. Enter a name for your formula property.
  4. Type your formula in the Formula field.
  5. 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:

Examples:

Use operators

Arithmetic operators perform math on numbers:

Comparison operators compare values:

Boolean operators combine logical conditions:

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:

Examples:

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:

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.