What is FormulaMap()?
FormulaMap is a Coda formula that takes a list of items and returns that list after each item has had another formula applied to it. The FormulaMap function takes two inputs:
A list of items
A formula to apply to each item in that list
FormulaMap() is a really powerful formula, but understanding how to use it properly takes some learning and some trial and error. This powerful formula is found in almost all programming languages, where it's more commonly referred to as a map. You can also thing of FormulaMap() as a for each loop.
How do I use FormulaMap()?
The FormulaMap function takes two inputs:
A list of items, which could be a list of numbers, a list of rows (aka a table or a filtered table), or a list of text inputs.
A formula, which will be applied to each item in the list. Use
@CurrentValueto refer to the current item in the list.
A simple example
Say you have a list of numbers:
And you want to perform the same operation on each number in that list, in this case multiplying each number by 10.
You could accomplish that with a FormulaMap where the provided formula is CurrentValue * 10:
Real life examples
An astute reader might ask why you wouldn’t just use a table that has a list of numbers in it with a column formula to transform them — and they’d be right! That’s a much simpler solution.
But there are often situations where you can’t easily construct a table with the data you want to apply a formula to. Here are a few community threads where using the FormulaMap function proved helpful:
And here’s a full list of all community posts that mention a FormulaMap.