10 min read

The top five formulas you need to know.

Start adding formulas to your doc with these five essentials.

There are five formulas in the Coda Formula Language that you’ll use over and over again. By familiarizing yourself with these formulas, you'll be equipped to perform a wide range of tasks and calculations in Coda, manipulate and analyze data effectively, automate processes, and create dynamic and interactive docs. Let’s add these MVP formulas to your toolbox! 🧰

What’s in this guide.

You'll get...
  • Top 5 formulas you need to know
  • When and how to use these formulas in your docs
buttons
You'll use...
  • Formula builder
  • Dot operator
  • Coda Formula Language

1. Filter()

You’ll use the Filter formula when you want to look at part of a table to answer a question. The criteria for this formula can be as simple or as complex as you need. The basic structure of the filter formula is: [Table you want to look at].Filter([Part of the table you are interested in]).[What you want Coda to do with this piece of data]
In this example, we want to look at the Produce table, and specifically the Fruit or Vegetable column where items are marked as either Fruit or Vegetable. In this case, we just want the items marked Fruit. Lastly, we just want to pull the names of those items, so we'll use the dot operator to display the values in the Name column of all rows that match this Filter() criteria.

2. User()

The User() formula returns the current user’s name. In your Coda doc, open the formula builder in the canvas and type this: User() Then hit "Enter" - This should now display your name!
The User object in Coda holds a few key pieces of information:
  • The user’s name
  • The user’s email address
  • The user’s Coda avatar (photo)
You can use the dot operator to access the information held within the user object. Try out the following in your Coda doc:
  • User().Name
  • User().Email
  • User().Photo
Next, try this: Concatenate("Welcome to Coda, ", User().Name, ". Have a lovely day!")
Beyond using this formula for custom greetings, you can use it to:
  • Automatically assign tasks to whoever clicks a button
  • Combine it with Filter() and/or Contains() to create a dynamic, personalized view of a tasks or project table that automatically filters the tasks or projects assigned to whoever is logged in and viewing that table.

3. thisRow

In Excel, the smallest unit is a cell. Since Coda is a database at heart, the smallest unit is a row. When you create a Table, you can organize your data how you think about and describe it. Rows generally represent “things” (people, tasks, inventory items, places to visit, grocery list items, etc), and the columns are generally “attributes” of those things (their gender, age, address, etc). Working with rows, we can access all of the contextual details for each value (aka columns or attributes of the row). When building your table, you can use meaningful names for columns, and then when you need it, you can ask for things like “give me the age of this person” instead of “give me what’s in B2”. thisRow gives you the ability to take an item's contextual details with you and focus your formulas to pull data from each specific row. Because rows always travel together, you can use the thisRow formula component to do a few things within your formula, and you can combine this with the dot operator to show more context.
In this example, we’re using thisRow.Project to pull the due date of each project in the Project column for their respective rows.

4. Contains()

The Contains formula checks if a list contains a specified value. If the value is found, it returns true: List("Dog", "Giraffe").Contains("Cat", "Mouse", "Dog") = true Contains() and Filter() will be your best friends when working in Coda. You can combine the two to pull out specific info from tables, especially when working with multi-select columns where you might have multiple values in that column for a given row.
In this example, we’re using Filter() and Contains() together to pull a bulleted list of all the tasks in the Master - Tasks table with a status of In Progress.

5. If() and SwitchIf()

The If() formula

The If formula allows you to handle if/then logic. The basic structure of the If() formula is as follows: If(Condition, What you want to happen if this condition is true, What you want to happen if this condition is false)
In this example, we’re looking at a set of data and comparing the count of fruits vs vegetables in a table. If the Vegetable count is greater than the Fruit count, we want to display "We need more vegetables than fruit 🥦" otherwise, we want to display "We need more fruit than vegetables 🍎"

The SwitchIf() Formula

The SwitchIf formula lets you get a value conditionally. It handles multiple conditions with a fallback. The basic structure of the SwitchIf() formula is as follows: SwitchIf(Condition, What you want to happen if Condition 1 is true, Condition 2, What you want to happen if Condition 2 is true, Condition 3, What you want to happen if Condition 3 is true, ...)
SwitchIf() outputs the first value where the condition is true and exits the formula. If the first condition is false, it cycles through the rest of the conditions until it finds a true condition. It outputs an optional final value if none of the conditions are true. For example: SwitchIf(Today() > Date(2030, 01, 20), "Hello future!", Year(Today()) = 2023, "Hello present!", Today() < Date(2023, 17, 10), "Hello past!")
Similar to the If() example above, we’re comparing the count of fruits and vegetables in our dataset and telling SwitchIf() what we want to display in either case if the Vegetable count is greater or the Fruit count is greater. The third value in the formula is what SwitchIf() should display if all other arguments return False. Tip: You can use the SwitchIf() formula instead of long, nested if/then statements with the If() formula.

Now what?

Now that you've learned these essential formulas, it's time to expand your knowledge and add more formulas to your toolbox. Here are some additional resources that you can explore to keep flexing those formula muscles 💪 🧠

Was this helpful?

YesNo