I have used the lookup function and yes, it works fine. But, and hopefully am am overlooking something, I can’t find a way to return any other value than the display column value. I can change the display column, but I need to be able to return more than one value (column) after finding a record. In vlookup, you can reference the column, but in lookup, I can’t find a comparable parameter. Is this a limitation, or did I miss something?
You can use the dot operator to project values for a column. For example =Tasks.Lookup(AssignedTo, thisRow).TasksColumn
will find all rows in the Tasks table where the AssignedTo matches the current row, and then projects the TasksColumn property of those rows.
Does that help?
@joost_mineur This post below (“Players and Leagues” doc) has helped me to conceptualize how lookup works and dispelled the doubts regarding as to how I should use it. I think it’ll help as I had encountered the same problem as you have.
Thank you both for your feedback - this answered my question. It works and it’s very easy to use (once you know…).
Funny to see how you can write it two ways: “Tasks.Lookup(AssignedTo, thisRow).TasksColumn” returns the same values as “Lookup(Tasks,AssignedTo, thisRow).TasksColumn”. It kind of worries me that I could not find this myself looking through the documentation (might very well be me, I am (very) old school). But I am glad to find out it can be done so easily.
For what it is worth to other newbe’s: I would never want to rely on whatever is marked as display column - it seems easy to do so, but the display column can be changed and all of your formula’s that depend on this column would fall apart.
Dear @Kris_Murawski could you help me with below case?
I want the table Annual to get the price data from the Unit Price column in table Initial. How can I do this without changing the display column? Thank you in advance!
I would do it like that:
Annual.Filter(PN.Contains(thisRow)).[Unit Price]
Thank you very much @Przemek_Sawicki
What about below scenario, when the PN column in the “Initial” table is looking up the data from the “Annual” table. I am trying to get the logic. Would you say this is a right way of using Coda? I don’t want to be limited to using display columns only for lookups.
Have you simply try something like this ? :
thisRow.PN.[Unit Price]
Aha thank you Pch. Still learning thank you. I am getting red-dots in the corner for all rows except 1st. Do you know why?
You’re welcome
I think the format of your Price
field is the culprit and maybe the format for Unit Price
too
Both should be a Currency
field (or at least the same format)
My personal trick for this is that I almost always call the display column “Name” and then not mess with it.
So I can easily code: Fruits.Name and Vegetables.Name and Categories.Name.
Since the display column always defines what the table is about, it doesn’t need a separate title.
Thank you @Pch appreciate your help
I am having the same issue and tried this but it’s just returning …
[Comments with Manager].lookup([Comments with Manager].Comment,thisRow).Manager is my formula
Comments with Manager is the table and I’m trying to pull in the value from the Manager column based on the Comment matching the comment in this row.
The comments are long values of text, could that be why it’s not working?
Hello @Mykaela_Doane1,
If you show a simplified sample of what you are trying to accomplish and what the table data looks like, it is a lot easier to help you. I don’t think that the comments are the problem.
Greetings, Joost