Gallery
The Self-Writing Doc: How to build reports that write themselves
Share
Explore

icon picker
Canvas formula tips

How to use canvas formulas to build natural language generation in Coda.
Below we've broken down a few of the fundamental building blocks that we used in this doc. But don't limit yourself to these examples - there are lots of ways to create text generation!
Show off your own NLG docs in the !

Example 1: Using the SWITCHIF() function


The SWITCHIF() formula is an easy way to generate flexible text in Coda. For example, switch between different games using the dropdown below. Notice how the sentence changes👇.
WASHINGTON
- - The
@Nationals
faced off against the
@Braves
on
Sunday
in what turned out to be a
rainy
day at
Nationals Park
.
👏Cool right?
We can extend that by adding in a second sentence about the outcome of the game:
The
@Braves
dominated
with a final score of
7
-
1
.
Notice how we can change "won" to "barely won" using our outcome definitions found in .

Example 2: Using the RANDOM() function


This is an example of using the RANDOM() formula to make each game summary a little different. Each phrase is randomly selected from to add some pizzaz to the summary.
Take a look at the RANDOM() formula in the Top moment text gen column. It's a little complicated, but the basic text gen logic is:
[Player] + [Top moment phrase] + [Amazing play]
You'll notice that each time a change is made to the doc (typing, clicking, refreshing, etc.), the top moment phrase changes. This is because the RANDOM() formula selects a new number each time the Coda doc recalculates. If this drives you crazy, change the formula to RANDOM(false), which keeps the formula from recalculating.
Player
Individual highlight
Top moment
@Jimmy Halpert
brought the fans to their feet with an incredible
catch👋
.
@Jimmy Halpert
brought the fans to their feet with an incredible
catch👋
.
@Oscar Martino
made Sport Center's Top 10 with an unbelievable
defensive play🛡
.
No results from filter
Try adding in new "top moments" phrases below👇 and notice that they randomly appear in the Top moment text gen column above 👆(after the RANDOM() formulas recalculate a few times).
Number
Phrase
1
had an amazing
2
wowed the crowds with a bold
3
really turned the momentum with a
4
brought the fans to their feet with an incredible
5
made Sport Center's Top 10 with an unbelievable
6
came up clutch with a hall-of-fame-worthy
7
stepped up with a textbook
8
left the other team speechless after a super-charged
There are no rows in this table

Back to:

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.