Photo by J E S U S R O C H A on Unsplash | How to Code variables

How to Coda (non) variables?

about Concatenate() and Format() and how they differ

When I started using Coda, one of the first functions that resembled familiair to me was Concatenate(). I knew it from Excel and it was a rather easy to use function I applied when I had to glue stuff together based on values in cells. For quite some time I used this function to define a unique value in the display column or to create a dynamic label in a button.

This changed when I noticed that Community Members as Paul & Federico showed a preference for Format() over Concatenate(), like here.

Both functions have in common that they blend variables with non variables in a specific way.

I’ll explain Format() and maybe you will see that this is often an easier to apply function, although this might not look like this at all at first glance.

How does Format work?

Inside the function Format() you have two parts. The fist part is between “ “ and is separated via a comma from the variables in the second part. In the first part you see numbers in the {} and they reference to the variables in the order as put in the second part, thus after the comma. Below an example:

Format(Hi {1} , you are invited to vote!”, <- First Part
2nd Part -> Sequence(1,VotingTable.InviteAll.Listcombine().Count()).
FormulaMap(thisRow.InviteAll.Nth(CurrentValue).Split(" ").First()))

and the same function written in a concatenate:

Concatenate("Hi ", Sequence(1,VotingTable.InviteAll.Listcombine().Count()).FormulaMap(
thisRow.InviteAll.Nth(CurrentValue).Split(" ").First()))," you are invited to vote!")

The first advantage is that the Format function reads better and this is mainly due to splitting the non variable part from the variables after the comma. You also don’t have to start and end the text values with “ “ all the time.

Once could argue that it is possible to shorten the Concatenate using WithName() and indeed that is true. However if you do so, you do something that is already provided for in the Format function. Here not with a ‘name’ but with a number.

Formatting with Format part 1

While the Format() function easier reads and writes in many cases as the Concatenate() there is an additional advantage that is simply not present in the Concatenate() This is toe possibility to format how the outcome looks.

As you can see in the post of Federico:

If for example the date format of the destination is European (“DD/MM/YYYY"), you can create a European Date column (with Text datatype) with the following formula:
Format("{2:00}/{1:00}/{3}", thisRow.[Your Date].Split("/")

This solution shows two major advantages:

  • you can format the value by adding “:00” which will create a number type 01 or 09, thus two digits.
  • you can reference one item (here a date), split it (here by “/”) and reformat it in the order of your choice using 3 variables in the first part all referencing the same value in the second part.

Formatting with Format part 2

I happens you want to have values on a next line and for most of the time I went with Character(10) inside a Concatenate(). It works, but is not so elegant compared to what the format function offers, see below:

and the above results in:

The format function permits you by putting the elements inside the function on an other line to have your data on next lines. Isn’t that elegant and easy?

Do I still use concatenate?

O yeah, once in a while when I am in a hurry and it is about blending some texts nicely. It goes fast and if the values you reference to are in a column you put them right after the text and you are set. The moment I need a tiny bit more, I rely on Format.

I hope you enjoyed this article. If you have questions feel free to reach out. Though this article is for free, my work (including advice) won’t be, but there is always room for a chat to see what can be done. Besides you find my (for free) contributions to the Coda Community and on Twitter

My name is Christiaan Huizer and I am the owner of Huizer Automation. A company specialized in serving SME in harvesting data and keeping it aligned. I am a Coda Expert and rely mainly on Coda, Mailjet, Zapier & Paperform to get the job done.

Huizer Automation — Coda Expert on How to Coda (non) variables?

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Christiaan Huizer

Christiaan Huizer

I use Coda mainly for planning & calculations of all sorts. Follow me to learn how to Coda with numbers. I blog at least once per week.