SOLVED

How to use Xlookup with spilled range as lookup value? I want the range to spill horizontally.

%3CLINGO-SUB%20id%3D%22lingo-sub-2116575%22%20slang%3D%22en-US%22%3EHow%20to%20use%20Xlookup%20with%20spilled%20range%20as%20lookup%20value%3F%20I%20want%20the%20range%20to%20spill%20horizontally.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2116575%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20attaching%20the%20sample%20file.%3CBR%20%2F%3E%3CBR%20%2F%3EIn%20%22Cal%22%20sheet%2C%20I%20want%20a%20single%20cell%20formula%20in%20A2%2C%20to%20lookup%20values%20in%20subsequent%20columns%3CBR%20%2F%3E%3CBR%20%2F%3EFor%20some%20reason%20Xlookup%20is%20spilling%20lookup%20vertically%20in%20rows.%3C%2FP%3E%3CP%3EIs%20there%20a%20fix%20to%20it%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2116575%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%20for%20web%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%20on%20Mac%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%20on%20mobile%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2116992%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20use%20Xlookup%20with%20spilled%20range%20as%20lookup%20value%3F%20I%20want%20the%20range%20to%20spill%20horizontally.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2116992%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F523656%22%20target%3D%22_blank%22%3E%40Nishkarsh31%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhat%20is%20better%20depends%20on%20with%20which%20you%20are%20more%20familiar.%3C%2FP%3E%0A%3CP%3EMATCH()%20by%20default%20performs%20approximate%20search%20which%20is%20not%20reliable%2C%20that's%20the%20main%20difference.%20XMATCH()%20has%20more%20options.%20In%20your%20case%20not%20a%20big%20difference.%3C%2FP%3E%0A%3CP%3ESEQUENCE%2FCOLUMNS%20-%20good%20enough.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2116796%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20use%20Xlookup%20with%20spilled%20range%20as%20lookup%20value%3F%20I%20want%20the%20range%20to%20spill%20horizontally.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2116796%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%20sir%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%20need%20to%20know%20why%20we%20used%20Xmatch%20over%20match%2C%20I've%20gotten%20the%20same%20results%20with%20Match.%3CBR%20%2F%3E%3CBR%20%2F%3EAlso%20to%20make%20the%20columns%20dynamic%2C%20I've%20used%20this.%3CBR%20%2F%3EIs%20there%20a%20better%20solution%3F%3CBR%20%2F%3E%3CBR%20%2F%3E%3DINDEX(Enrolment%2CMATCH(A2%23%2CEnrolment%5BName%5D)%2CSEQUENCE(1%2CCOLUMNS(Enrolment)-2%2C2)%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2116644%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20use%20Xlookup%20with%20spilled%20range%20as%20lookup%20value%3F%20I%20want%20the%20range%20to%20spill%20horizontally.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2116644%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%20IMHO%2C%20last%20resort%20is%20Power%20Query%2C%20but%20it%20depends%20on%20entire%20project.%20I'm%20not%20sure%20recursive%20LAMDA%20works%20in%20such%20case%20on%20relatively%20big%20data%20source.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2116640%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20use%20Xlookup%20with%20spilled%20range%20as%20lookup%20value%3F%20I%20want%20the%20range%20to%20spill%20horizontally.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2116640%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F523656%22%20target%3D%22_blank%22%3E%40Nishkarsh31%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWith%20%3CSTRONG%3EXLOOKUP%3C%2FSTRONG%3E%20you%20can%20either%20perform%20the%20lookup%20row%20by%20row%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3D%20XLOOKUP(%40Names%23%2C%20Enrolment%5BName%5D%2C%20Enrolment%5B%5BA%5D%3A%5BC%5D%5D)%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3Eor%20you%20can%20do%20it%20column%20by%20column%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3D%20XLOOKUP(Names%23%2C%20Enrolment%5BName%5D%2C%20Enrolment%5BA%5D)%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3Ebut%20it%20will%20not%20return%20a%202D%20array%20(Excel%20doesn't%20like%20arrays%20of%20array%20-%20yet)%3C%2FP%3E%3CP%3EIt%20is%20possible%20to%20collect%20the%20rows%20or%20columns%20together%20using%20a%20recursive%20%3CSTRONG%3ELAMBDA%3C%2FSTRONG%3E%20function%20(365%20beta)%20but%20that%20would%20be%20something%20of%20a%20last%20resort.%26nbsp%3B%20In%20this%20case%20%3CSTRONG%3EINDEX%2FXMATCH%3C%2FSTRONG%3E%20is%20superior%20to%20%3CSTRONG%3EXLOOKUP%3C%2FSTRONG%3E.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F252972i74877E20720A98FC%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EI%20did%20post%20a%20UserVoice%20request%20for%20this%20to%20be%20improved%20but%20right%20now%2C%20I%20can't%20even%20find%20UserVoice%2C%20never%20mind%20my%20suggestion.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2116626%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20use%20Xlookup%20with%20spilled%20range%20as%20lookup%20value%3F%20I%20want%20the%20range%20to%20spill%20horizontally.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2116626%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F523656%22%20target%3D%22_blank%22%3E%40Nishkarsh31%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20variant%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DINDEX(Enrolment%2CXMATCH(A2%23%2CEnrolment%5BName%5D)%2C%7B2%2C3%2C4%7D)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Contributor

I'm attaching the sample file.

In "Cal" sheet, I want a single cell formula in A2, to lookup values in subsequent columns

For some reason Xlookup is spilling lookup vertically in rows.

Is there a fix to it?

5 Replies
Best Response confirmed by Nishkarsh31 (Contributor)
Solution

@Nishkarsh31 

As variant

=INDEX(Enrolment,XMATCH(A2#,Enrolment[Name]),{2,3,4})

 

@Nishkarsh31 

With XLOOKUP you can either perform the lookup row by row

= XLOOKUP(@Names#, Enrolment[Name], Enrolment[[A]:[C]])

or you can do it column by column

= XLOOKUP(Names#, Enrolment[Name], Enrolment[A])

but it will not return a 2D array (Excel doesn't like arrays of array - yet)

It is possible to collect the rows or columns together using a recursive LAMBDA function (365 beta) but that would be something of a last resort.  In this case INDEX/XMATCH is superior to XLOOKUP.  

 

image.png

I did post a UserVoice request for this to be improved but right now, I can't even find UserVoice, never mind my suggestion.

@Peter Bartholomew , IMHO, last resort is Power Query, but it depends on entire project. I'm not sure recursive LAMDA works in such case on relatively big data source.

Thank you sir@Sergei Baklan 

I need to know why we used Xmatch over match, I've gotten the same results with Match.

Also to make the columns dynamic, I've used this.
Is there a better solution?

=INDEX(Enrolment,MATCH(A2#,Enrolment[Name]),SEQUENCE(1,COLUMNS(Enrolment)-2,2)

@Nishkarsh31 

What is better depends on with which you are more familiar.

MATCH() by default performs approximate search which is not reliable, that's the main difference. XMATCH() has more options. In your case not a big difference.

SEQUENCE/COLUMNS - good enough.