Switch statement to return tables

Hi Community,
I’m trying something simple, but it’s not working and I don’t understand why.
I want to press one button to copy all the items of a table to three different tables depending on the “Target” property of each item.
I’ve tried to do it with a simple switch:

    [Table A],
    [Table B],
    [Table C]
  Description, thisRow.Description, Name,thisRow.Name
From what I understand, the "AddRow" will take one of the tables and implement CurrentValue.Description = thisRow.Description. It only works for Target A, the first of the switch list, as if only that one was eligible to CurrentValue. I wonder what's the logic I'm missing.

Interesting use-case. My only thought is that you may need a switch to specify the table.column for each column.

You might want to try with SwitchIF function. Something like SwithcIF (thisrow.Target=“A”, [Table A], etc.) . Cant test this atm moment but I think it should work

1 Like

Thanks for the reply,
Actually, I am intrigued by my lack of understanding of the syntax. (should it work? why doesn’t it?)
In my view, “CurrentValue” called in a “column” argument inside an “AddRow” function should consider whatever value is passed by “table” argument inside the same function (which is what the Switch statement would provide). But it only works for Table A (the first table to be declared) as “CurrentValue” (see image).
Weirdly enough, it passes some tests for other conditions, AND they actually find the table, only to inform “Column Description is not present on Table B”, even though it is present.

i would suggest putting the Switch() on the front of your formula with 3 different complete AddRow() formulas for each case. i suspect the Coda formula editor/parser will then more clearly understand which columns to use.

    [Table A].AddRow(Description, thisRow.Description)
    [Table B].AddRow(Description, thisRow.Description)
    [Table C].AddRow(Description, thisRow.Description)



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