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.[SourceColumn], 
    If(thisRow.[SourceColumn].IsBlank(), '',
      thisRow.[SourceColumn].Filter([Target].Contains(CurrentValue))
    )
  ),
  [Target].Filter([TargetColumn].Contains(thisRow)).IfBlank(List()).ListCombine(
  thisRow.[SourceColumn].IfBlank(List())).Unique().FormulaMap(
    WithName(CurrentValue, Row,
      Row.ModifyRows([TargetColumn], 
        thisTable.Filter([SourceColumn].Contains(Row))
      )
    )
  )
)

Don’t want to have to manually write the formula? Use the Automatic Formula Generator

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 )))

1 Like

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

@Connor_McCormick1 @Aaron_Moritz — would you be able to share the code for the self-referential table that includes the ‘if empty’ case? I’d be very grateful!

1 Like

:wave: Hi! I’m Ramesh, a PM at Coda.

We are opening a new beta for a new linked relationships feature (aka bi-directional lookups), that make things like setting up Projects + Tasks, Recipes + Ingredients easier. We are adding a new column type called Linked Relation that represents the other side of this relationship to a Relation (formerly known as Lookup). When you add a new Relation column, a Linked Relation column is created automatically. Editing is enabled on both sides by default.

Existing “Reverse Lookup” columns added via the “Referenced by” menu option will be auto updated to Linked Relation with editing enabled

We’d love to have you try this out and get your feedback. If you’re interested, please fill out this form and see this page for other betas that we are running.

Please note that signing up for beta access to this feature will enable it only for you and your docs in your workspace (both existing and new).

Linked Relationships - Projects and Tasks

3 Likes