Create Table entries based on other table row

Dear Community,

I do have a problem, which I want to solve as elegantly as possible: I have a table of devices (Smart home, not really relevant). This table does include a field “Number of Channels” and “Channel Ordering Style”. Based on those two values, I want to automatically create a number of entries in my table “channels”, linking to the respecting device and naming the rows according to the “Channel Ordering Style”.

Device Table:
Device Name, No. Channels, Ordering Style
Device 1, 3, Alphabetical
Device 2, 4, Numerical
Device 3, 2, Current Phases
Device 4, 2, Cable

Port table
Port Name (Formular: join(“-”, Device, Ordering Name), Device, Ordering Name
D1-A, Device 1, A
D1-B, Device 1, B
D1-C, Device 1, C
D2-1, Device 2, 1
D2-1, Device 2, 2
D2-1, Device 2, 3
D2-1, Device 2, 4
D3-L1, Device 3, L1
D3-L2, Device 3, L2
D4-brown, Device 4, brown
D4-black, Device 4, black

I hope this makes sense.
Now my first idea was using an automation, which does not work from my perspective. The other idea I had, is a row button, but I cannot figure out an elegant way to solve the flexible creation. Also, it would be even better not to need any button but create and update automatically.

Does anyone have an idea?

Thanks a lot!

I have created a doc (at bottom of page) that does this by use of coda’s equivalent of for loops from a button press.

I have created a third table “Ordering Style” where you define what you want to iterate through if not obvious such as alphabet or numerical. This isn’t necessary and you could just type the list into the button formula, but I dislike hardcoding these kinds of things.

The button will run through a for loop for each type of ordering style. Here is a quick rundown in a more programmy set up of the button (pictured below).

  • Alphabetical:
    For (letter) in (A to char(Number of Channels) {
    name = “device-(letter)”
    device = thisDevice
    ordering style = (letter)
  • Numerical:
    For (number) in (1 to Number of Channels) {
    name = “device-(number)”
    device = thisDevice
    ordering style = (number)
  • Else:
    For (number) in (1 to Number of Channels){
    For (listItem) in (list(1) to list(number)){
    name = “device-(listItem)”
    device = thisDevice
    ordering style = (listItem)

In its current stage it does require the button to be pressed, however, you can set up an automation to click the button when a new row is created

Here is the doc

1 Like

Thanks you so much, this is perfect. :+1:
Also the tip with the automation for the trigger of the button did fill the last gap to what I wanted to archive.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.