Lookup() doesn't work with relation/reference column?

Hey People,
I’m porting my recipe book from sheets to Coda.

Ingredients table has ingredients and info about them.
Recipes table has all the recipes and one of the columns is an ingredient.

I use formulas to pull and calculate details based on ingredients eg.
Lookup(Ingredients ,Ingredients.Name , thisRow.Ingredients).[GBP / ml]*thisRow.Amount

As you can see it works perfectly fine if Ingredients column is a raw text.

But I want that column to be a relation pulling/allowing only ingredients already added in their table. The moment I change they column type lookup breaks and all lookup values go to zero.

This has to be a bug, right?
View for that doc is public, I hope to publish it for everyone when I’m done.

Hi @Landsil,

A couple of things …

The doc you’ve shared isn’t editable so it’s not possible to inspect the formulas, relations etc. Could you create a copy of the doc and share that? (So that folks can make changes/suggestions without messing about with the original doc)

The Coda recommendation is to use Filter instead of Lookup and that may give you the results you are after?

Hi @Landsil

Few things:

Yes, lookup() has been superseded by filter().

From your description it is not clear whether you want to report existing relationships, or whether you want to create new relationships. Formulas, both lookup and filter will only report on existing relationships between the two tables.

If that is what you want to do, the reason your formulas fail when you change the column type, is you are no longer comparing apples to apples. When you make the column a relation, you will see that the text nie has a little bubble around it. This means that the column no longer contains simple text, but contains a reference to another table.

One way to restore the formula to working is to add .totext() at the end of the relational reference.

Not able to see the document, and being on my mobile, this is my best guess.

P

2 Likes