Forum Discussion
LOOKUP Expression?
Hello,
I have two sheets in an Excel document, Data 1 and Data 2.
Data 1 has Columns [Participant] and [Area].
Data 2 has the same columns but the [Area] is empty.
I would like to know how to fill in the [Area] in Data 2 based on [Participant] number?
Thank you in advance.
14 Replies
- PeterBartholomew1Silver Contributor
I have a feeling that you are getting towards the size of problem where Power Query might offer the best solutions (this is included in the workbook).
Otherwise, searches are currently far more efficient if you sort the lookup table by participant.
Then the formula
=LOOKUP(VALUE([@Participant]), tblArea)
will look up a participant in the first column of tblArea and return the corresponding value from the second column.
p.s. If you are an Office 365 user I believe that this distinction between exact searches and binary searches will soon disappear as the field you are searching will be sorted in memory before the first search, making subsequent searches very fast.
- SergeiBaklanDiamond Contributor
PeterBartholomew1 , I don't think on 10-20 thousand rows with so simple range it could be any issues with performance with any approach. Minus of Power Query it requires refreshing. Not a big issue with static data, but if you add records from time to time and shall to shift from one table to another to check only one additional attribute - that could be annoying.
- PeterBartholomew1Silver Contributor
I am absolutely sure you are correct with the problem as it stands. Out of curiosity where would you put the balance point (if one has to switch to Calculation Manual the cut-off point has probably been passed)? Would you expect 10s of thousand searches over 100s of thousand values to go well? I don't have much experience with large datasets that bring Excel grinding to a halt!
Another factor that might influence the decision is 'How is the additional data input?' If a PQ append query offers the best route to import data, then one might choose to continue with the join query even when LOOKUP or INDEX/MATCH might otherwise be fast enough.
- SergeiBaklanDiamond Contributor
- KC_86Copper Contributor
SergeiBaklan
I tried to apply the same expression for different spreadsheets but it didn't work because of the wrong data type. Could you advise me how should I fix the error? I used your expression before and it worked on other sheets but not this one.
I want to look up the Dosage value in EVENT tab based on the Event Code columns for PARTICIPATION tab.Thank you.
- SergeiBaklanDiamond Contributor
KC_86 , you don't need double dash here since event code is the text in both sheets. Previous time you have numbers in one sheet and texts as numbers in another one.
=INDEX(EVENT!F:F,MATCH($E2,EVENT!E:E,0))
- KC_86Copper Contributor
SergeiBaklan
I tried to apply the same expression for different spreadsheets but it didn't work because of the wrong data type. Could you advise me how should I fix the error? I used your expression before and it worked on other sheets but not this one.
I want to look up the Dosage value in EVENT tab based on the Event Code columns for PARTICIPATION tab.Thank you.
- Kim_WennerbergCopper ContributorSergei,
Can you explain the double-dash used in the MATCH function? (--$C2)- SergeiBaklanDiamond Contributor
Kim, there are numbers as text in column C, and in lookup column we have numbers. Double dash converts texts to numbers. Same as VALUE() here.