Reference Column Name with String

#1

It would be great to be able to reference columns with procedural strings.
When you have a large number of columns but with predictable names, this would be very useful.
I’ll try to explain the use case for clarity.

Let’s say we have these columns.

  • Column 1
  • Column 2
  • Column 3

I’d like to be able to do:
thisRow.(Concatenate("Column"," 3"))

That would give me thisRow.[Column 3] but I currently can’t make it work.

I suppose I could change the topic title to “Reference Object Name with String”, columns are one of the use cases.

A possible solution would be to make brackets usable like this
thisRow.[(Concatenate("Column"," 3"))]

But I get the feeling that if it was that simple, the Coda team would have done it already. Things are much more complicated behind the scenes, I can barely imagine. :sweat_smile:

Another solution would be to have a specific function like ToObject or ToColumnName
thisRow.ToColumnName(Concatenate("Column"," 3"))

Thank you for taking the time!

5 Likes

#2

I really like the idea of ToColumnName to be explicit about wanting to turn a string into a column name reference. I actually don’t think this is too complicated, but rather if implemented incorrectly could cause a lot of confusion for novices. That is why I like the idea of ToColumnName, because it is explicit, and would only be used by people who really know what they want.

Lloyd

1 Like