How can I do a recursive formula?

I have a project table where each project can have dependencies, which are also project (the dependencies column is multi-select lookup that points back to the project table).

I’d like to generate a bullet list of projects that are dependencies for each row in the table. typically I would do this with recursion. I was wondering how I might do this in a formula in coda. Any suggestions?

thanks,
Mark

This might set you in the right direction

Thanks. that did the trick. I’ve been able to build lists of dependencies.

Now, I’d like to do something a little different. I want to create a filtered view of the projects such that the view contains the projects that match a criterion(project.team = blah) and those projects’ predecessor projects. I thought I could do with a formulamap, but that is not doing anything for me. any suggestions?

Make a column on each project that lists its predecessors (not bulleted, just like the “Path” column in the example) - maybe you’ve already done this as part of your solution to your first problem.

Then your filter formula is something like:

project.team = blah OR
project.predecessors.filter(currentValue.team = blah).count() > 0

Basically you filter the predecessors list, and see if at least one predecessor matches the team

sorry, I wasn’t more clear. I do have the predecessors in a column (from you earlier answer). Now what I want to do is merge the list of projects with team = blah with each of their predecessors. the resulting list will eventually contain projects where team != blah.

Could you share a version of your doc that shows where you want this to display? E.g. is it another column, or a new view of the table with certain filter settings applied?

I can’t share the document. I am trying build a filtered view that shows projects (filtered by team) with their predecessors.

actually, I think I have it. I have 2 columns to test: predecessors and successors. Here is a formula that I think captures all possibilities:

thisRow.Team.Contains([RTL.Retail Orders]) OR
thisRow.Successors.filter(currentValue.Team.Contains([RTL.Retail Orders])).count() > 0 OR
thisRow.Predecessors.filter(currentValue.Team.Contains([RTL.Retail Orders])).count() > 0

1 Like

I came across this post. Not sure if it’s still relevant for you, but I have figured out a recursive lookup, that makes is possible to make trees/ hierarchical structures.
If you’re interested, have a look here:

Best Regards Lars Kristian

3 Likes

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