Skip to content
Gallery
Format() External Templates
Share
Explore

icon picker
Variables & Constants

Now that you know how to use in your docs (if you want to 😉), using variables and/or constants shouldn’t be a problem as it works following the same principles 😊.
(And yes, this is also something I discovered thanks to
on his 🙌)

Variables and constants - Info 💡

From :
In , a constant is a that should not be altered by the during normal execution, i.e., the value is constant. When associated with an identifier, a constant is said to be "named", although the terms "constant" and "named constant" are often used interchangeably. This is contrasted with a , which is an identifier with a value that can be changed during normal execution, i.e., the value is variable.

In Coda 😇

Variables and constants in Coda are those values you need to use in a formula somewhere in a table (or on the canvas) which can be calculated only once, in a helper table, instead of calculating them for each row in that table.
This can be very useful in terms of performances but also, to re-use such values throughout the entire doc 😊 (without the need to recalculate them, once again).

A common example of variable/constant : Now()

I’ll admit when using variables/constants in Coda, I personally don’t take their general definition into account and just create solely variables 😇.
One of the variable I use the most is Now() as depending of the precision, Now() can quickly create performance issues (as if you need “seconds”, it means that Now() gets recalculated every seconds, for “minutes”, it will be recalculated every minute and so on...).
As mentioned before, using variables/constants in a doc, works like using but instead of storing templates, you store those calculated values you wish to use in your formula in a single row helper table and in your formula, you @-ref the needed variable/constant where needed 😊.
If you need more variables/constants in your doc, just add a column (instead of rows, in this case) 😉.
Here👇 is an example when using Now() as a variable in 😊 (the other variables are used in the canvas formula below)
Variables
Handle
Now
Today Tasks Count
Task / Tasks
1
var_tasks
8/6/2024, 4:18 AM
0
no task
There are no rows in this table
Tasks
Name
Due
Status - Using @var_tasks.Now
Status - Using Now()
1
Task 1
9/1/2021, 1:30 PM
Overdue
Overdue
2
Task 2
9/11/2021, 11:00 AM
Overdue
Overdue
3
Task 3
9/3/2021, 10:00 AM
Overdue
Overdue
4
Task 4
9/5/2021, 4:30 PM
Overdue
Overdue
5
Task 5
9/17/2021, 1:30 PM
Overdue
Overdue
6
Task 6
9/8/2021, 11:30 AM
Overdue
Overdue
7
Task 7
9/3/2021, 7:00 AM
Overdue
Overdue
8
Task 8
9/13/2021, 8:00 PM
Overdue
Overdue
9
Task 9
9/1/2021, 2:00 PM
Overdue
Overdue
10
Task 10
9/19/2021, 4:00 PM
Overdue
Overdue
There are no rows in this table

And here’s what the Debug Calculation tool told me while I was adding tasks to 😊
Debug Calculation.png
Unsurprisingly, using
@var_tasks
instead of Now() will be better for the doc on the long run 😊, as we add more and more rows to the table.
Now() as a variable is the most obvious example I could find to illustrate this method but there are others 😉.
There can be lots of “repeating” calculated values in a doc 😊. Values which could be calculated, only once, outside of the table instead of calculating them /per row 😊.
👇 And of course, you can use both and in one formula 😊.
Hi
@Anonymous User
😁!
Today is Tuesday and you have no task on your To Do List 😇
Templates 2
Handle
Template
Description
1
welcome_2
Hi {1} 😁!
Today is {2} and you have {3} on your To Do List 😇
User()
var_tasks.Now.WeekdayName()
var_tasks.[Today Tasks Count] / var_tasks.[Task / Tasks]
There are no rows in this table

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.