Row based Coda
A remedie to inefficient spreadsheet logics
In this blog you read how to create a table prefilled with dates, related properties and other variables. I created this in response to a question in the community you find here.
As you can read in this blog, I became a moderate enthousiast about showing tables to doc users. Most people get an uncomfortable feeling, maybe even a panic attack when they see formulas based on functions they don’t understand. There is more than one good reason to keep tables out of sight in many scenarios. However it happens you want to show parts of a table in a specific manner and this approach is a possible way out.
It is all about the row based logic dominating Coda tables. You do not create 365 columns with dates, you create one and this one has 365 (or 366 in 2024).
Step 01 — creating dates
We start with the creation of dates and related properties in a table. You may want to have such a table for all sorts of reasons. I remember that in certain planning tools we needed this. We work in a few steps.
- We create a canvas button
- We apply the function
AddRow()
- We create a list of dates using
Sequence()
- We do something with each date using
ForEach()
- We name the outcome applying
withName()
- We relate date properties like month name and so on
Below how that goes. It is good to follow. Each item in the list of dates as generated by the function Sequence()
— generates numbers between start & end number, whereby dates are numbers is added tot the tabel DB Tracker.
When you push the button, you get something like below. Hereby you should know that I created already other tables for the weekday names, the week numbers an the month names. I used some standard coda formatting (they offer 24 color variations) in these tables. In general relations are smarter than select lists. A select list may feel as an easy starter, but it never delivers on its promise to make things really easy in my not so humble opinion. In short, avoid using select lists as you can.
Step 02 — adding activities
Per date we can have various activities, The math is simple. when we have two activities, we have (remember we prefill a table) 2 * 366 rows, 3 activities it is already 3 * 366 and so on. Adding activities is based on the table DB activities.
Below how it looks like when we push the button. As you can see 1098 rows are added.
The logic is that we added per row three items via a forEach()
on each item of the list in DB Activity. We named that function to theActivitiy .When you look at the forEach()
function, you see the [ ] and in between 3 actions. The [ ] indicate a list. You have 366 lists and each item contains 3 items.
Step 03 — add frequency, activities and dates
So far it was rather easy and the good news is that it remains easy. We apply the same logic. This time related to the frequency, which is also based on a table. As said before, I work with relations, not with select lists.
As you notice, the multiplication of rows goes fast. If you add one column with 3 variations you get 13K rows. That becomes a serious table. There are no formulas active — that is on purpose and so the table remains rather fast.
Have a look at the lists, now you see we have lists within lists. That is how it works, we create a list, then al list and now we have a list in a list in a list. Even if you don’t understand it, simply try it and you see how easy it is to replicate this logic.
Filtering on table values
In most occasions we don’t want to do this for a year and often we want to filter the outcome like only weekdays and activities related to certain weekdays. That makes the table smaller and the code a bit more difficult.
Below is the outcome of what you see in the last screenshot. It is not rocket science, nor a higher form of math. This is low code. In JavaScript this would take a bit more effort.
The code part you need shows the filters I applied.
Simply try it and the rest follows. In this doc you can test the buttons.
My name is Christiaan and blog about Coda. Since the summer of 2023 mainly about how to Coda with AI to support organisations dealing with texts and templates. The latest Coda AI update was on Dec 7, 2023.
Why I focus on Coda AI you can read here: ⤵️
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. 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.t