Auto populate lookup column with all rows in lookup table?

Hi, I’m not even quite sure how to phrase this question, but is there a way to auto-populate a lookup column with all of the values in the table it is referencing?

I have a big data table with 1,300 rows. I want to create a new table that references that table – with maybe three other columns from that table – and I’d then like to add some new data in additional columns. Is there a way to have the main lookup autopopulate with all of the rows?? I’d prefer not to have to manually type in all of the item numbers …

I figure there must be a way to do this, but I can’t quite figure it out.

1 Like

hi @Christina_Crowder ,

There is no need to do anything manually. We have buttons to do the job for us. In my example you see how I have a source table & a target table.

The code in the button you find below:

Source.Name.Unique().Foreach(AddRow(target,target.Name,CurrentValue))

Let me know if this works for you,

Cheers, Christiaan

2 Likes

oh… wow. that looks like wizardry on the first look but I will see if I can replicate on my data. thank you very very much for taking the time to make the demo! cc

um… stretch goal?? Is there a way to pull those unique values from two different tables into one column using a variation on this technique?

I have two tables: “Heft” and “Mak” …

identifiers in “Heft” look like this - 02-37-1026

identifiers in “Mak” look like this - Mak3-130-296

In other words, items in heft and mak each have identifying numbers, but they’re built slightly differently, and for some other reasons I’d like to be able to work with things in “heft” a little differently than with “mak” at some times, but then to work with / have access to all of the number (items) at other times.

If I set up the button you propose referencing “Heft” Is there a universe in which I could add another “Foreach” string to reference “Mak” too??

I’m wrestling with the sort of global question of whether I should create a universal large table that shoehorns the Heft and mak item identifying components into the same source columns. That would solve the problem of being able to see everything together. I believe I could then use filters to hive out the “Heft” and “Mak” items into different workflows.

Do you have an opinion on that??

Thanks much.

hi @Christina_Crowder ,

well something like this. Both Mak & Heft values are put in the target table.. If you keep the same names as below, this code works for you.

Runactions(
Heft.Name.Unique().Foreach(AddRow([target table],[target table].Name,CurrentValue)),

Mak.Name.Unique().ForEach(AddRow([target table],[target table].Name,CurrentValue))
)

May it be that Heft & Mak have very much the same properties, you can put data together.

Cheers, Christiaan

1 Like

thanks a lot Christiaan, I think I’m leaning toward putting them together and then using filters to do additional work on the heft/mak data. The initial google sheet work on the items was done as a combined sheet, so the original column headers are the same. I’ll see about merging what I’ve already set up in Coda. many thanks for the input. Lastly, I’ll definitely use the button/formula info to do other work down the road.

@Christina_Crowder

a good way to proceed would be to have a table like DB Brands below and use this brand via a lookup per item.

Over time working like this will avoid many issues.

Cheers, Christiaan

wow – great idea! thanks so much!

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