Skip to content
Mastering Coda's Formulas
  • Pages
    • All Formulas
    • Filter
      • All People
    • WithName
    • Format
    • Sequence
    • Split
    • icon picker
      FormulaMap

FormulaMap

The formula which will unlock more automation and Coda magic than any other

Before everything - What is this formula?

FormulaMap() allows you to define an action or formula and then run that action/formula individually on each item in a list.

Take this list of numbers for example:
1234

First choose what you want to do to each item in the list
0
3
to
each number
Notice how it changes our original list of numbers
Output:
4567

First - let’s just learn how it works.

The FormulaMap() formula is like saying:
Hey Coda, Im going to give you a list of items - Can you do the exact same action with each item in the list?
FormulaMap() takes two arguments
List
A list of items that you want Coda to indiviudally perform an action on
Formula
This is the formula Coda will perform on each item in the given list

Lets look at a quick example with a list of states:

AlaskaAlabamaArkansasArizona

Heres some quick actions FormulaMap() can do to each word

FormulaMap() making them Upper Case:
ALASKAALABAMAARKANSASARIZONA
FormulaMap() making them Lower Case:
alaskaalabamaarkansasarizona
FormulaMap() finding the words length:
6787
FormulaMap() checking if the words starts with “ala”:
truetruefalsefalse
FormulaMap() deleting every vowel from the word:
lsklbmrknssrzn

Don’t forget currentValue

The phrase currentValue has a special meaning within the formulaMap() formula. It is used to access the current value within the list. Take this list for example:
1234
The first time formulaMap() runs, the currentValue is 1
The second time formulaMap() runs, the currentValue is 2
The third time formulaMap() runs, the currentValue is 3
The fourth time formulaMap() runs, the currentValue is 4
currentValue will be used every time you write a formulaMap() formula
These examples are fun and show how the formula works, but now let’s find out how to use it to unlock some magic in your Coda docs and workflows.

Second - Where and how to use this

Let’s look at a concrete example of how you can use this to unlock some magic in your Coda docs. Lets pretend that you are preparing to lead a Jedi school to teach upcoming users of the force to master their powers, but you don’t discriminate between those drawn to the light-side or the dark-side.
Obviously though, depending on which side (dark or light) a student is drawn too, they will need different lessons focusing on different things.
Therefore we are going to make three tables
A template database called that holds the list of lessons available
A students database called that holds one row per student
A lessons database called that holds one row per lesson per student

Lets start with a database of lessons where each lesson is tagged either as one meant for the dark-side, the light side, or both
Lessons
Lesson
Lesson is for:
Turn on a lightsaber
Fight with a lightsaber
Learn to Pilot an X-Wing
Learn to Pilot a Tie-Fighter
Learn to be really cruel
Learn to be really compassionate
There are no rows in this table
Now that we have a set database of lessons, lets populate these lessons for individual students depending on what side of the force they are drawn to with the click of a button. This is where the magic of formulaMap() happens.
Students
View
Name
Drawn Towards
Add All Lessons
All lessons
Luke Skywalker
Added
Luke Skywalker
Luke Skywalker
Luke Skywalker
Luke Skywalker
R2-D2
Added
R2-D2
R2-D2
R2-D2
R2-D2
Darth Vader
Lessons
[  ]
Leia Organa
Lessons
[  ]
Beru Whitesun lars
Lessons
[  ]
Biggs Darklighter
Lessons
[  ]
Obi-Wan Kenobi
Lessons
[  ]
Anakin Skywalker
Lessons
[  ]
There are no rows in this table
This table below is the database of lessons that each individual student needs to complete. Click the
button above in each students row to see their tasks populated and mark them off as complete/incomplete
DB Lessons
Done
Student
Lesson
Turn on a lightsaber
Fight with a lightsaber
Learn to Pilot an X-Wing
Learn to be really compassionate
Turn on a lightsaber
Fight with a lightsaber
Learn to Pilot an X-Wing
Learn to be really compassionate
There are no rows in this table
You can click into the buttons options to see the formula used to assign lessons, but written in plain english, this is what it is doing:
First, we filter the database to find only the rows that are appropriate to the current student. This creates the list that is the first argument of your formulaMap() formula. It is the list that we will perform a individual action on
Now that we have our target list of lessons, we define the action that we will perform on each item. The chosen action in this case is for each applicable lesson, add a new-row for that student to the table
Thats it! There are so many possibilities with formulaMap() and the best way to find those is to start building docs of your own using this magic formula!


Want to print your doc?
This is not the way.
Try clicking the ··· in the right corner or using a keyboard shortcut (
CtrlP
) instead.