10 min read

# Intro to Coda's formula syntax

An introduction to Coda’s formula language.

### What’s in here.

What you'll get in this guide:

- An understanding to Coda's formula language
- An intro of chaining v. wrapping
- The basics of formula chips

What you’ll use in this guide:

- Formula builder
- Dot operator
- Formula chips

### The Coda formula language explained

The Coda formula language is similar to spoken or written words; it's a language. This means that although there are rules to improve efficiency and comprehension, there is no one singular way to accomplish anything. Think about all the ways you might greet someone. “Hello,” “hey there,” and “howdy” all look different, but they accomplish the same thing linguistically. You might choose one over the other depending on context: where you are, who you’re speaking to, etc. When you’re working with the Coda formula language, your way of writing might differ from the way other makers write their formulas—and that’s okay! The other thing to remember is that you don’t need to know every word in the dictionary in order to be a proficient speaker, and the same goes for the Coda formula language. You don’t need to know every formula to be successful, but we do have our formula dictionary should you ever need it 🧠.## 1. Breaking down a Coda formula.

Coda formulas are made up of two major components: objects and functions. To stay with our language analogy, you can think of objects as nouns and functions as verbs.### Objects

If you’ve ever used Excel or Google Sheets, you may be used to using coordinates to pinpoint a cell. In Coda, all**objects**(like tables, rows, and buttons) have names. No coordinates needed! Simply type the name of the object you want to reference. Objects hold the data we want to work with:

- A table is an object.
- A column is an object.
- A row is an object.

### Functions

Back to the sentence metaphor, functions (sometimes called formulas) are the verbs. They*do*stuff. Functions are things that we want to do to or with the given object:

`Filter()`

: filter the given dataset down based on specific criteria.`Count()`

: count the given dataset.`toText()`

: convert the given dataset to plain text values.

## 2. Formula chips.

Your objects will show up as**chips**in your formulas. When you click on a chip, you can learn more about that specific object. When we click on

**Fruit**chip in this formula example above, we can see that this is an option in the

**Fruit**or

**Vegetable**column in the

**Produce**table.

### Color coding tells you the location.

Formula chips of the same color mean that those objects are located in the same table. Take a look at this example. Based on the color of the chips, you can see that Produce and Fruit or Vegetable are part of the same table, and`thisRow.Category`

is part of the **Categories**table.

### Icons tell you the type and quantity of data.

Take a look at the reference table here. These icons will be at the far-right of each chip in your formulas, and they will note what**type**of data you're working with. The icon will also tell you whether you are referencing a

**singula**r value, a

**list**of values, or an array of values. Notice the “stacked” icons for lists:

## 3. Formula syntax.

The Coda formula language is a little bit Excel, a little bit JavaScript. What we mean by that is that you can choose to use the**wrapping**method or the

**chaining**method while writing your formulas.

### Wrapping

In Excel’s formula language, you use a lot of parentheses. This is called**wrapping**. This syntax is totally valid in the Coda formula language, but as your formulas become longer and more complex, this method can become a bit difficult to read as the number of parentheses increases.

### Chaining

In Coda, you can also get the same answer this way 👉 This is called**chaining**. The chaining method allows you to write your formulas in a more sentence-structured way, similar to JavaScript syntax.

### Parentheses.

Much like in math, things inside of parentheses can be viewed as one statement, or one sentence. Coda is going to look at that one statement and evaluate it as a whole. In lengthy formulas, parentheses will help note where one sentence ends and the next begins. You can click on a parenthesis to see its highlighted pair. This will show you where your sentence begins and ends. Additionally, just like in math problems, you'll use parentheses to separate multiple`AND`

and `OR`

functions so that all of your calculations happen in the right order. Coda will calculate anything inside of a parentheses first:`AND`

or `OR`

functions should be grouped. By default, the formula applies the logic from left to right in the order that it appears. If you want to specify a specific order, just use parentheses 😉### The dot operator.

With the help of the**dot operator**, you can use the chaining method to write formulas for better readability. Chaining separates steps in your formula by using a dot operator, which is just a fancy descriptor for a

**period:**

`"."`

At its most basic level, chaining with the **dot operator**looks like this:

- Equal to:
`=`

- Not equal to:
`!=`

- Less than:
`<`

- Greater than:
`>`

- Less than or equal to:
`<=`

- Greater than or equal to:
`>=`

- And:
or`&&`

*(not case-sensitive)`AND`

- Or:
or`||`

*(not case-sensitive)`OR`

## Now what?

Now that you’ve learned the basics of the Coda formula language, check out these other resources to keep flexing those formula muscles 💪 🧠- Formulas 101 | Coda Courses
- Formula Essentials | YouTube - Coda HQ
- Troubleshooting your formulas | Coda Help Center
- Good habits: how to write and troubleshoot big formulas | Coda.io Gallery

Was this helpful?

YesNo