Photo by Hasan Almasi on Unsplash

How to add a row in Coda?

distributing a single item or multiple items over rows

Christiaan Huizer
5 min readFeb 7, 2023

--

Almost every day I am adding rows in the same or in another table. Mostly directed by a button pressed manually. Many makers wrestle with a specific use case like in this question. It is about how to distribute multiple items living in one row over as many rows are there are items.

Multiple items in a cell

I believe that even

has adapted my slogan that in everything is a list. As a result when we apply a function, we evaluate or manipulate items in a list. Evaluation means we look at the properties and we apply a rule using a function like count all items, or count only odd items, or filter out people with the first name ‘Christiaan’ and so on. Manipulate means we print the outcome of a (compound) function as item in a cell using a button. The link with the source data is gone because only the outcome is printed as text and not living in a column as a function that recalculates each time the data changes. Buttons are one of the super powers of Coda, but like driving a Ferrari or Lamborghini, it requires a bit of training.

Single Row

In the button you follow the steps and it works. Below an alternative for a button on the canvas following the same procedure.

button on th canvas

You click the button and fill out and you see this. The Modal opens in full screen.

modal opens after clicking button

and the code behind all this is surprisingly simple:

code to add a single row

Simple Distribution

When we have multiple items in a cell we have list of items. Since

does not do the counting for us — as she does when items are distributed over rows in a table — we have to set up our own counting and we create a virtual index. This means that we create a number range corresponding with the items, using Sequence() and each item gets a position via Nth(). Below how this works.

A variation on this one I gave as feedback in the community. We count the items in the list, we attribute a position via a virtual index and we press the button.

It is a bit more complex when you want to avoid doubles in your target table, but not very much.

Complex Distribution

The two variations above most readers applied already in their docs, at least that is what I assume. The next one is a bit more complicated, but good to follow. It is about only adding rows when the item does not yet exist in the target table. This means that we filter out the already in place items and next only add the new ones.

Our starting point are again multiple employees in one cell like below.

distribute only not yet present employees

I left a column visible showing the employees to add. It is this function we need in our button. You also notice that I disable the button once there are no employees left to distribute. That is a practical solution and avoids incomprehensible

error messages. Below the solution that makes use of a Filter() and asks for items not present.

In this solution you notice the same pattern. The extra element is the filter we apply on the thisRow and we rename as the outcome. We count the items in the Outcome and we apply the previous logic. This all goes rather fast when you understand that everything is a list in

.

Via this doc you can test how it works.

We can always increase complexity, but this blog ends here. In other blogs I will write about complexer functions. I have one in mind about a Sequence(). Indeed I use the below shown technique to access sub lists.

My name is Christiaan and I support SMB with calculations (budgets and — Human Resource — planning) and I prefer using Coda to get the job done.

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.

Coda comes with a set of building blocks ー like pages for infinite depth, tables that talk to each other, and buttons that take action inside or outside your doc ーso anyone can make a doc as powerful as an app (source).

Not to forget: the Coda Community provides great insights for free once you add a sample doc.

expert Christiaan on “How to add a row in Coda?”

--

--

Christiaan Huizer

I write about how to Coda . You find blogs for beginners and experienced makers. I publish about 1 / week. Welcome!