When I first started at Coda, I heard the formula language was incredibly powerful and that it helped turned docs into apps. Because I love a good challenge, I headed to
and started scrolling....and scrolling...and scrolling. There were TONs of formula components available. I started to feel a bit disheartened.
Fast forward to today. Am I a master of every formula on that page? Heck no. Is it because Coda is smarter than me? Well, maybe a little, but mostly because I learned a secret. To get what I need from 95% of my docs, I only need 5 formulas.
If I could only have one Coda formula, it would be Filter(). Filter formulas are a great way to customize your table, whether you're creating a new view in a different section or refining the data in your original table. Filter helps you look at just a portion of your data to answer questions like “How many of these tasks are urgent?” and “Which of these books did Erin rate 5 stars?”
The basic structure of filter is:
[Table you want to look at].Filter[Part of the table you’re interested in].[What you want Coda to do]
In the formula above, we want to look at the table of blog posts, see the posts where the category is “Launch,” and know how many of those posts there are.
You can be as involved with the filter portion as you like. You’re not tied to a simple equals. You can use AND, OR, <, >, true, false, and any combination of these.
People are an important part of Coda—after all, we can’t get everything done by ourselves. Since folks log in to work with you in Coda, you can use the User() formula to create a customized experience. By typing =User() into Coda, your doc will automatically display the name of the person logged in looking at the doc. For example:
Welcome to my doc,
. 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 to create a dynamic “My Tasks” view that automatically filters the tasks to whoever is logged in.
If you’ve used a spreadsheet before, you know that formulas usually name a place in a grid, like A6+B123. Coda’s formula language takes a different approach.
In Coda, the smallest unit is the row. Think of it this way: That task isn’t just the name of the task. You also want to know who owns it, when it’s due, how long it will take, and more. A row is comprised of all of these data points!
Because rows always travel together, you can use the thisRow formula component to do a few things. And you can use a
to show more of the context. In the table below, I’m using the
to show me who is the project lead.
You can also use thisRow to summarize information across your tables. In the table below I’m showing the number of tasks for each person on the team.
Contains and Matches are the formula components that let you map tables to controls like dropdown menus.
You’ll use Matches if you have a single select list or a date range. In this example, I want to know how many blog posts were published in May.
You’ll use Contains for everything else. This makes sure that if your criteria is included, even in a multi-select list, you’ll be covered.
When in doubt, use Contains!
The last formula components that I use all the time are If and SwitchIf. These let me build responsive results based on my choices. You’ll use If in an either/or situation and you’ll use SwitchIf if there are multiple options.
If(condition, What you want to happen if that condition is true, What you want to happen if it’s false)
In this example, if the Out Of Office is not blank, then I want to show their manager’s email as the contact.
SwitchIf is the same, except that you can include as many options as you like:
SwitchIf(Condition 1, Result if that is true, Condition 2, Result if that is true....)
In this example, I have a different person assigned based on the status of the project.
Focus on trying these formulas, and see how your docs soar. If you ever need help, don’t hesitate to get in touch. You might also want to check out our formula fitness webinars for a few deep dives. You’ve got this!