Formula help - Generating a list of instances where an item appears in other lists

Hi - I’m new to Coda and I’m trying to write a formula for a column of a “part” that generates a list of every “assembly” instance this “part” exists in. This list would contain the names of the “assemblies”.

Basically I have a list of parts ie resistor 10 ohm, capacitor 1 uF, transistor 2n4401… and these parts are used in multiple assemblies. I’m trying to create a list that looks for all the assemblies that contain a specific part. Any help would be appreciated.

Jamie

Jamie, welcome to the community!
Could you share an example doc and an example of what kind of output you’re looking for?

Hi @Jamie_A,

your Used In column formula should be

Assemblies.Filter(Includes=thisRow)

Let me know if you need any further clarification.
Cheers!

Thanks for your response @Federico_Stefanato. It still only prints the display of the row item’s name.


I want it to display the Assembly name(s) that the item is used in. Do you know how to do this?

Thanks, Connor. I just fixed my original post to display the screenshot. The output that I’d like is the red text. It should look at the Assemblies table and print the instances in the Assembly column that the item is mentioned in the Includes column. Does that make sense?

Hi @Jamie_A ,
two ways:

  1. you explicitly select the property of the row you want to see (be aware: in this case you’ll have a list of String - not Assemblies - in the Used In column).
Assemblies.Filter(Includes=thisRow).Assembly
  1. In the Assemblies table, you define the Assembly as the “display column” (in the drop-down menu of the column)

Let me know.

2 Likes

Thanks Federico! Yes both of these work. I don’t quite understand the difference between the two. In the first way (explicitly selecting the property) it prints the value in square brackets and in the other way it doesn’t. What does this mean?

Happy that you found a way!

It’s a matter of data type.

When you filter - or lookup - value(s) of a table (Assemblies.Filter(...)) you get a list of rows.
you can then access their attributes (or properties or members) by selecting the relative column.

For instance,
Assemblies.First() will give you the first row of Assemblies table (or an Assembly object).
By setting the display column, you just say how you “see” that row, but it’s still an entire row.

When you step into the rows properties, you’ll get the relevant information.
e.g. you can get the Manufacturer Id of the first row by selecting its proper column:
Assemblies.First().MFG ID

So,
Assemblies.Filter(Includes=thisRow)
will give you the list of rows and you’ll see what you set in the display column

Assemblies.Filter(Includes=thisRow).Assembly
will give you a list of String (the value of each Assembly column).

I hope I made it more clear not vice versa… :grimacing:

I’m sure that playing around with Coda you will get more and more familiar with these concepts that come from the Relational model (in case you are more curious: Relational model - Wikipedia)

Enjoy!

5 Likes

Yes thank you this makes sense. You’re right that I think I need to keep using Coda to see what situations one works better than the other. Thanks so much.

1 Like

Excellent explanation Federico!

1 Like