Workaround: Linked Columns | Reverse Lookup | 2 Way References

Check this out:
Linked Columns

You can automatically push those buttons with the help of an automation, and boom you have bidirectional linking of tables.

See the doc here: Linked Columns In Coda · Linked Columns

Now that this has been in action for a while, I wanted to share the formula in a way that would make it simple to reference:

RunActions(
  thisRow.ModifyRows(thisRow.LocalColumn, 
    If(thisRow.LocalColumn.IsBlank(), '',
      thisRow.LocalColumn.Filter(TargetTable.Contains(CurrentValue))
    )
  ),
  TargetTable.Filter(TargetColumn.Contains(thisRow)).IfBlank(List()).ListCombine(
  thisRow.LocalColumn.IfBlank(List())).Unique().FormulaMap(
    WithName(CurrentValue, Row,
      Row.ModifyRows(TargetColumn, 
        thisTable.Filter(LocalColumn.Contains(Row))
      )
    )
  )
)

Don’t want to have to manually write the formula? Use the Formula Generator · Linked Columns

6 Likes

thx @Connor_McCormick1 , it is very well and friendly explained for those who understand coda already quite a bit

what is the story behind Avoid a Coda bug with ListCombine → IfBlank(List()

cheers, Christiaan

1 Like

@Christiaan_Huizer Thank you! Here’s an explainer on the ListCombine bug:

Linked Columns · Linked Columns In Coda - Watch Video

1 Like

hi @Connor_McCormick1 , thx again, now I see your point.

I came across IfBlank(List)) as a way to avoid a comma before a user when you want to add multiple users in a cell, that is a different application of the same formula.

I really like the way you present, it is enthusiastic, clear and playful, keep adding!

2 Likes

The reason you are getting invalid action is because listcombine(" "," ") isn’t an action, whereas in your Update buttons, the listcombine() is chained with an action, modifyrows()

Go try ListCombine(List(), List()) in a button. No error, yet also not an action.

what do you want / expect a button to do with that? you don’t have a destination for it to put the results

I tried to explain in the video the intended use. How could I make it clearer?

I’m talking about the canvas button on the bottom in your video example, not in the table, there is no action. This is a separate error than when you run the action modifyrows() and one of the calculated lists is empty.

Ah yeah that’s just a demo of how to trigger the error. I believe it’s the same error, otherwise why would adding IfBlank(List()) fix the problem?

Thanks for this. Helped me do something I’ve been wanting for a while which is have a lookup column in a table that references that same table, and have it so that if I add row B to row A’s lookup column, then row A will automatically show up in row B’s lookup as well.

My button formula ended up being
thisRow.[Linked Entries Column].ifblank(list()).FormulaMap(ModifyRows(CurrentValue, [Linked Entires Table].[Linked Entries Column], listcombine([Linked Entries Column].ifblank(list()),thisRow )))

Oh very interesting! If they’re in the same table, why do you need to have two separate columns?

There is only one lookup column

I just want it so if I enter row B into that lookup column for row A, I don’t then have to go to row B to enter row A in there. It goes both ways.

One way I’m using it is in a table of random links, images, notes, and other stuff, all in one table. Kind of just an ‘inbox’ table of notes and stuff. This is an easy way to just see at a glance other entries I have designated as ‘linked entries’, and I only have to define the link in one direction for it to be automatically added in the other direction as well

1 Like

Ahhh… so it’s like linked columns turned sideways. Very cool I would have never thought of that. Grabbing your formula for my reference later:

thisRow.[Linked Entries Column].IfBlank(List()).FormulaMap(
  CurrentValue.ModifyRows(
    [Linked Entires Table].[Linked Entries Column], 
    ListCombine(
      [Linked Entries Column].IfBlank(List()),
      thisRow 
    )
  )
)
3 Likes

I’m waiting for codans to release this feature for some time and then you come with this simple and clever workaround. Impressive!

1 Like

Added a Formula Generator · Linked Columns and updated the formula after finding some edge cases

3 Likes