Skip to content
Gallery
WithName
Share
Explore

icon picker
WithName

Formula: WithName()
Category: Relational
megaphone.svg
WithName()
Names a value to be used inside of an expression
It’s kind of like saying...
Hey Coda, I’m 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() uses three parameters:
exposure-value (11).svg
Value

WithName(Value, Name, Expression)

The value you want to rename (usually a short forumula).
identification-documents.svg
Name

WithName(Value, Name, Expression)

The name you want to give the value (i.e., the "sweet nickname".
google-code (2).svg
Expression

WithName(Value, Name, Expression)

The primary formula--you use the renamed value in here.

What Exactly 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

How Does it Work?

Here’s a quick example. Let’s say that I want to draft a sentence that tells me how many people in the have a name that starts with “A” and the average age of those people. WithName() allows me to do that easily.
There are 1 people whose name starts with 'A' and the average age of those individuals is 11.

And here’s the formula I wrote to draft that sentence

image.png

Here’s how that formula breaks down

(1) The “Value”:

People Database.Filter(name.StartsWith(”A”)

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

Let’s Get Deeper

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 (see lesson for more info on current value) within the ForEach() loop.

Example

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


Done
Create a “Learn about a tree” activity
Done
Done
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.