SOLVED
Home

LOOKUP Expression?

%3CLINGO-SUB%20id%3D%22lingo-sub-581653%22%20slang%3D%22en-US%22%3ELOOKUP%20Expression%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-581653%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20two%20sheets%20in%20an%20Excel%20document%2C%20Data%201%20and%20Data%202.%3CBR%20%2F%3EData%201%20has%20Columns%20%5BParticipant%5D%20and%20%5BArea%5D.%3CBR%20%2F%3EData%202%20has%20the%20same%20columns%20but%20the%20%5BArea%5D%20is%20empty.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20would%20like%20to%20know%20how%20to%20fill%20in%20the%20%5BArea%5D%20in%20Data%202%20based%20on%20%5BParticipant%5D%20number%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20in%20advance.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-581653%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-581699%22%20slang%3D%22en-US%22%3ERe%3A%20LOOKUP%20Expression%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-581699%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F320138%22%20target%3D%22_blank%22%3E%40KC_86%3C%2FA%3E%26nbsp%3B%2C%20it%20could%20be%3C%2FP%3E%0A%3CPRE%3E%3DINDEX('Data%201'!B%3AB%2CMATCH(--%24C2%2C'Data%201'!A%3AA%2C0))%3C%2FPRE%3E%0A%3CP%3Eand%20fill%20it%20down%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-581713%22%20slang%3D%22en-US%22%3ERe%3A%20LOOKUP%20Expression%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-581713%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EIt%20works%20beautifully!%20Thank%20you%20very%20much.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-581731%22%20slang%3D%22en-US%22%3ERe%3A%20LOOKUP%20Expression%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-581731%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F320138%22%20target%3D%22_blank%22%3E%40KC_86%3C%2FA%3E%26nbsp%3B%2C%20you%20are%20welcome%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-582484%22%20slang%3D%22en-US%22%3ERe%3A%20LOOKUP%20Expression%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-582484%22%20slang%3D%22en-US%22%3ESergei%2C%3CBR%20%2F%3ECan%20you%20explain%20the%20double-dash%20used%20in%20the%20MATCH%20function%3F%20(--%24C2)%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-582499%22%20slang%3D%22en-US%22%3ERe%3A%20LOOKUP%20Expression%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-582499%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F342713%22%20target%3D%22_blank%22%3E%40Kim_Wennerberg%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EKim%2C%20there%20are%20numbers%20as%20text%20in%20column%20C%2C%20and%20in%20lookup%20column%20we%20have%20numbers.%20Double%20dash%20converts%20texts%20to%20numbers.%20Same%20as%20VALUE()%20here.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-583587%22%20slang%3D%22en-US%22%3ERe%3A%20LOOKUP%20Expression%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-583587%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20not%20finding%20it%20necessary%20to%20use%20double%20dash%20to%20convert%20%22FALSE%22%20to%200%20in%20Excel%20Office%20365.%26nbsp%3B%20I%20can%20just%20act%20as%20if%20FALSE%20is%20a%200%20or%20TRUE%20is%20a%201%20and%20use%20it%20in%20other%20formulas.%26nbsp%3B%3C%2FP%3E%3CP%3ECell%20A2%20resolves%20to%20FALSE%3C%2FP%3E%3CP%3ECELL%20A3%20contains%20%3DA2*3%20and%20displays%200%3C%2FP%3E%3CP%3ESame%20behavior%20with%20TRUE.%26nbsp%3B%20Double%20dash%20seems%20no%20longer%20necessary.%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-583995%22%20slang%3D%22en-US%22%3ERe%3A%20LOOKUP%20Expression%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-583995%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F342713%22%20target%3D%22_blank%22%3E%40Kim_Wennerberg%3C%2FA%3E%26nbsp%3B%2C%20that's%20not%20about%20TRUE%20and%20FALSE%2C%20that's%20about%20MATCH%3C%2FP%3E%0A%3CPRE%3E%3DMATCH(%222%22%2C%7B1%2C2%2C3%7D%2C0)%20returns%20%23N%2FA%0A%3DMATCH(--%222%22%2C%7B1%2C2%2C3%7D%2C0)%20returns%202%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-584006%22%20slang%3D%22en-US%22%3ERe%3A%20LOOKUP%20Expression%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-584006%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F320138%22%20target%3D%22_blank%22%3E%40KC_86%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20a%20feeling%20that%20you%20are%20getting%20towards%20the%20size%20of%20problem%20where%20Power%20Query%20might%20offer%20the%20best%20solutions%20(this%20is%20included%20in%20the%20workbook).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOtherwise%2C%26nbsp%3B%3CSPAN%3E%20searches%20are%20currently%20far%20more%20efficient%20if%20you%20sort%20the%20lookup%20table%20by%20participant.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EThen%20the%20formula%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%3DLOOKUP(VALUE(%5B%40Participant%5D)%2C%20tblArea)%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3Ewill%20look%20up%20a%20participant%20in%20the%20first%20column%20of%20tblArea%20and%20return%20the%20corresponding%20value%20from%20the%20second%20column.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3Ep.s.%20If%20you%20are%20an%20Office%20365%20user%20I%20believe%20that%20this%20distinction%20between%20exact%20searches%20and%20binary%20searches%20will%20soon%20disappear%20as%20the%20field%20you%20are%20searching%20will%20be%20sorted%20in%20memory%20before%20the%20first%20search%2C%20making%20subsequent%20searches%20very%20fast.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-612137%22%20slang%3D%22en-US%22%3ERe%3A%20LOOKUP%20Expression%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-612137%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F214174%22%20target%3D%22_blank%22%3E%40Peter%20Bartholomew%3C%2FA%3E%26nbsp%3B%2C%20I%20don't%20think%20on%2010-20%20thousand%20rows%20with%20so%20simple%20range%20it%20could%20be%20any%20issues%20with%20performance%20with%20any%20approach.%20Minus%20of%20Power%20Query%20it%20requires%20refreshing.%20Not%20a%20big%20issue%20with%20static%20data%2C%20but%20if%20you%20add%20records%20from%20time%20to%20time%20and%20shall%20to%20shift%20from%20one%20table%20to%20another%20to%20check%20only%20one%20additional%20attribute%20-%20that%20could%20be%20annoying.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-612520%22%20slang%3D%22en-US%22%3ERe%3A%20LOOKUP%20Expression%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-612520%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20absolutely%20sure%20you%20are%20correct%20with%20the%20problem%20as%20it%20stands.%26nbsp%3B%20Out%20of%20curiosity%20where%20would%20you%20put%20the%20balance%20point%20(if%20one%20has%20to%20switch%20to%20Calculation%20Manual%20the%20cut-off%20point%20has%20probably%20been%20passed)%3F%26nbsp%3B%20Would%20you%20expect%2010s%20of%20thousand%20searches%20over%20100s%20of%20thousand%20values%20to%20go%20well%3F%26nbsp%3B%20I%20don't%20have%20much%20experience%20with%20large%20datasets%20that%20bring%20Excel%20grinding%20to%20a%20halt!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnother%20factor%20that%20might%20influence%20the%20decision%20is%20'How%20is%20the%20additional%20data%20input%3F'%26nbsp%3B%20If%20a%20PQ%20append%20query%20offers%20the%20best%20route%20to%20import%20data%2C%20then%20one%20might%20choose%20to%20continue%20with%20the%20join%20query%20even%20when%20LOOKUP%20or%20INDEX%2FMATCH%20might%20otherwise%20be%20fast%20enough.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-623977%22%20slang%3D%22en-US%22%3ERe%3A%20LOOKUP%20Expression%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-623977%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EI%20tried%20to%20apply%20the%20same%20expression%20for%20different%20spreadsheets%20but%20it%20didn't%20work%20because%20of%20the%20wrong%20data%20type.%20Could%20you%20advise%20me%20how%20should%20I%20fix%20the%20error%3F%20I%20used%20your%20expression%20before%20and%20it%20worked%20on%20other%20sheets%20but%20not%20this%20one.%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EI%20want%20to%20look%20up%20the%20Dosage%20value%20in%20EVENT%20tab%20based%20on%20the%20Event%20Code%20columns%20for%20PARTICIPATION%20tab.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-623978%22%20slang%3D%22en-US%22%3ERe%3A%20LOOKUP%20Expression%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-623978%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EI%20tried%20to%20apply%20the%20same%20expression%20for%20different%20spreadsheets%20but%20it%20didn't%20work%20because%20of%20the%20wrong%20data%20type.%20Could%20you%20advise%20me%20how%20should%20I%20fix%20the%20error%3F%20I%20used%20your%20expression%20before%20and%20it%20worked%20on%20other%20sheets%20but%20not%20this%20one.%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EI%20want%20to%20look%20up%20the%20Dosage%20value%20in%20EVENT%20tab%20based%20on%20the%20Event%20Code%20columns%20for%20PARTICIPATION%20tab.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-624130%22%20slang%3D%22en-US%22%3ERe%3A%20LOOKUP%20Expression%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-624130%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F320138%22%20target%3D%22_blank%22%3E%40KC_86%3C%2FA%3E%26nbsp%3B%2C%20you%20don't%20need%20double%20dash%20here%20since%20event%20code%20is%20the%20text%20in%20both%20sheets.%20Previous%20time%20you%20have%20numbers%20in%20one%20sheet%20and%20texts%20as%20numbers%20in%20another%20one.%3C%2FP%3E%0A%3CPRE%3E%3DINDEX(EVENT!F%3AF%2CMATCH(%24E2%2CEVENT!E%3AE%2C0))%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-624134%22%20slang%3D%22en-US%22%3ERe%3A%20LOOKUP%20Expression%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-624134%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EThank%20you%20very%20much%20for%20your%20help%20again.%20Now%20it%20all%20made%20sense.%20I%20just%20tested%20the%20expression%20and%20it%20worked%20beautifully.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
KC_86
Occasional Contributor

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
Solution

@KC_86 , it could be

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

and fill it down

@Sergei Baklan 

It works beautifully! Thank you very much. 

@KC_86 , you are welcome

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

@Kim_Wennerberg 

 

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.

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.

@Sergei Baklan 

@Kim_Wennerberg , that's not about TRUE and FALSE, that's about MATCH

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

 

@KC_86 

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.

 

@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.

@Sergei Baklan 

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.

@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.

@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.

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

 

@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
Tabs and Dark Mode
cjc2112 in Discussions on
38 Replies
Extentions Synchronization
Deleted in Discussions on
3 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
29 Replies
Security Community Webinars
Valon_Kolica in Security, Privacy & Compliance on
12 Replies