• 518K Members
• 8,613 Online
• 616K Conversations
SOLVED

## LOOKUP Expression?

Occasional Contributor

# 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?

14 Replies
Solution

# Re: LOOKUP Expression?

@KC_86 , it could be

`=INDEX('Data 1'!B:B,MATCH(--\$C2,'Data 1'!A:A,0))`

and fill it down

# Re: LOOKUP Expression?

@Sergei Baklan

It works beautifully! Thank you very much.

# Re: LOOKUP Expression?

@KC_86 , you are welcome

# Re: LOOKUP Expression?

Sergei,
Can you explain the double-dash used in the MATCH function? (--\$C2)

# Re: LOOKUP Expression?

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.

# Re: LOOKUP Expression?

I am not finding it necessary to use double dash to convert "FALSE" to 0 in Excel Office 365.  I can just act as if FALSE is a 0 or TRUE is a 1 and use it in other formulas.

Cell A2 resolves to FALSE

CELL A3 contains =A2*3 and displays 0

Same behavior with TRUE.  Double dash seems no longer necessary.

# Re: LOOKUP Expression?

```=MATCH("2",{1,2,3},0) returns #N/A
=MATCH(--"2",{1,2,3},0) returns 2```

# Re: LOOKUP Expression?

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.

# Re: LOOKUP Expression?

@Peter Bartholomew , 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.

# Re: LOOKUP Expression?

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.

# Re: LOOKUP Expression?

@Sergei Baklan

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.

# Re: LOOKUP Expression?

@Sergei Baklan

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.

# Re: LOOKUP Expression?

@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))`

# Re: LOOKUP Expression?

@Sergei Baklan

Thank you very much for your help again. Now it all made sense. I just tested the expression and it worked beautifully.

Related Conversations
Copy cell value from different table row
Edgar Soares in Excel on
2 Replies