10 min read
The top five formulas you need to know.
Start adding formulas to your doc with these five essentials.
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
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]
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’s name
- The user’s email address
- The user’s Coda avatar (photo)
User().Name
User().Email
User().Photo
Concatenate("Welcome to Coda, ", User().Name, ". Have a lovely day!")
- Automatically assign tasks to whoever clicks a button
- Combine it with
Filter()
and/orContains()
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.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.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 handleif/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)
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 theSwitchIf()
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!")
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