Mastering Coda's Formulas
Share
Explore

icon picker
WithName

The wonderful little formula that makes all things faster and new things possilbe

Before everything - What is this formula?

withName() is like the bit.ly of Coda. The mnemonic device of Coda.
Bit.ly
Takes long and complex URLs and shortens them

Mnemonic Devices
Takes long and complex phrases and creates a way to memorize them easily

withName()
Takes long and complex formulas and allows you to reference them easily

First - let’s just learn how it works.

The withName() formula is like saying:
Hey Coda, Im going to give you a long formula. I’ll probably want to use it later, so can you remember that formula by a sweet little nickname I give it?
withName() needs three things to make it work (or three parameters)
(1) The long formula: Your formula editor calls it the value

image.png
(2) The sweet little nickname you want to give it: Your formula editor calls this the name
image.png
(3) The formula you will write using that given nickname

image.png
Here’s a quick example. Lets say that I want to draft a sentence that tells me how many people in the table have a name that starts with “A” and the average age of those people. withName() allows me to do that easily.
There are 68 people who's name starts with 'A' and the average age of those individuals are 37.720588235294116
And here’s the formula I wrote to draft that sentence
image.png

Here’s how that formula breaks down

(1) The long formula:

AllPeople.filter(name.StartsWith(”A”)

(2) The sweet little nickname
aPeople
(3) The formula
Format("There are. . . ",aPeople.count(), aPeople.Age.Average())

Now - let’s learn how to unlock new possibilities in your doc

WithName() does require extra keystrokes and admittedly does have a small learning curve. So when and where should you use it to actually provide value to your workflows or docs?
First off - if you are writing a longer formula that utilizes filter() within a formulaMap() you will need to use withName() to access the currentValue within the formulaMap() loop.

If that sounded like Latin, let’s take a concrete example. To the left you will see a list of 10 individuals with age information. Let’s say you wanted to write a Canvas based formula to draft a summary list of the amount of people that match a certain age and let their names be instantly clickable in order to pull up their information. You will need to use withName() to do that.
Here’s the formula (Right click to see how its written)
There are 2 people that match the age of 20
@Craig Kidd
@Mr. Brian Montoya
There are no people that match the age of 21
There are 3 people that match the age of 22
@Bryan Johnson
@Jackson Fron
@Angie Collier
There are 3 people that match the age of 23
@Megan Smith
@Daniel Ayers
@Coda Man
There are 3 people that match the age of 24
@Ronnie Gross
@Thomas Ward
@Scott Weir
There is 1 people that match the age of 25
@Elizabeth Nguyen
There is 1 people that match the age of 26
@Angela Hill
There are no people that match the age of 27
There are no people that match the age of 28
There is 1 people that match the age of 29
@Matthew Smith

1
2
3
4
5
6
7
8
9
10
11
12
13
14
Name
Age
Craig Kidd
20
Elizabeth Nguyen
25
Ronnie Gross
24
Bryan Johnson
22
Angela Hill
26
Matthew Smith
29
Thomas Ward
24
Megan Smith
23
Mr. Brian Montoya
20
Daniel Ayers
23
Scott Weir
24
Coda Man
23
Jackson Fron
22
Angie Collier
22
There are no rows in this table


Share
 
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.