How to make relationships automatically apply to parent entries in a hierarchical table?

Hello, I want to use coda to create a game database with hierarchical genres. This is my current implementation so far. This is the table in which I create a genre hierarchy tree:

As you can see, genres will be hierarchical, with Retro FPS being a subgenre of FPS, FPS a subgenre of Shooter, and Shooter being a subgenre of Action.

I have another page with a Games table, and I will assign certain genres to games with a relationship column, like so:

image

However, here’s my problem. I want the relationship to follow the hierarchy that I have set. So I don’t want the game of doom eternal to show up only in the Retro FPS genre, like it does now.

I want it to automatically recognize my hierarchy, and automatically assign the game relationship to every parent. So I automatically want doom eternal entry to show up in the FPS, Shooter, and Action columns when I assign it to the Retro FPS genre, as per my hierarchy.

Do you know of a way to achieve this? I heard that formulas are pretty powerful but honestly I can’t wrap my head around them, and I would really appreciate some help and guidance.

Thanks!

Since I’m a new user, I can’t share more than one image, so I tried to create a link to my workspace so you can view what I’m talking about. Please let me know if you can’t access it.

Hello Teoman

I cannot access your doc. Make sure you have shared it with everyone or published it.

Regarding your question, the trick is to use a “recursive” formula. Below is a link to a doc where I reproduced your example. In the category table, I added a column that will combine all parents up to the root. The formula is simply ListCombine(parent, parent.AllParents).

In the games table, I added a formula that retrieves all parents from the selected category. It will include the selected genre, and to ensure each category shows just once, I added the Unique formula, resulting in this formula: ListCombine(categories, categories.AllParents).Unique().

To see the formulas, you can copy the doc to your workspace.

Best Regards,
Felipe Arnhold

I tested it just now and it seems to work perfectly, thank you so much!!

1 Like

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