SOLVED

LOOKUP to XLOOKUP Migration

%3CLINGO-SUB%20id%3D%22lingo-sub-2276926%22%20slang%3D%22de-DE%22%3ELOOKUP%20to%20XLOOKUP%20Migration%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2276926%22%20slang%3D%22de-DE%22%3E%3CP%3EHello!%20I%20am%20currently%20using%20the%20following%20LOOKUP%20formula%20for%20my%20real%20estate%20managment%20spreadsheet%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DLOOKUP(2%3B1%2F(Accounts!%24A%3A%24A%26gt%3B%3D%24EJ-3)%2F(Accounts!%24G%3A%24G%3D%24GD%204)%2F(Accounts!%24F%3A%24F%3D%22SHOULD%20VZ%20HK%22)%3B(Accounts!%24C%3A%24C))%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eto%20look%20for%20a%20date%20in%20row%20accounts!A%3AA%20smaller%20than%20the%20date%20given%20in%20%24EJ'3%20under%20the%20condition%20that%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3COL%3E%3CLI%3Eit%20matches%20the%20given%20account%20%24GD%204%20with%20row%20accounts!%24G%3A%24G%20and%3C%2FLI%3E%3CLI%3Eit%20made%20the%20given%20category%20name%20%22SOLL%20VZ%20HK%22%20with%20row%20accounts!%24F%3A%24F%3C%2FLI%3E%3C%2FOL%3E%3CP%3Eto%20return%20the%20found%20value%20in%20accounts!%24C%3A%24C.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20instance%3A%20On%20April%2017%2C%202021%20(%24EJ%243)%20for%20the%20account%20%22Ly1.OGre%20Miramar%20Privat%22%20(%24GD%204)%20it%20returns%20the%20value%2075.81%20which%20is%20the%20value%20for%20April%2C%201%2C%202021%20(april%20closest%20fools!)%20and%20the%20to%20April%2017%2C%202021.%20I%20would%20always%20need%20the%20value%20of%20the%20date%20one%20instance%20earlier%20than%20the%20given%20date.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20the%20desparate%20need%20to%20speed%20up%20my%20spreadsheet%20with%2016k%20rows%20of%20data%20(it%20takes%20over%201%20minute%20to%20calculate)%20I%20wanted%20to%20speed%20things%20up%20and%20translate%20my%20LOOKUP%20formula%20into%20an%20XLOOKUP.%20I%20thought%20I%20would%20need%20a%20nested%20XLOOKUP%20similiar%20to%20Example%20No.%205%20in%20%3CA%20title%3D%22https%3A%2F%2Fsupport.microsoft.com%2Fde-de%2Foffice%2Fxverweis-funktion-b7fd680e-6d10-43e6-84f9-88eae8bf5929%3Fui%3Dde-DE%26amp%3Brs%3Dde-DE%26amp%3Bad%3DDE%26amp%3BfromAR%3D4%22%20href%3D%22https%3A%2F%2Fsupport.microsoft.com%2Fde-de%2Foffice%2Fxverweis-funktion-b7fd680e-6d10-43e6-84f9-88eae8bf5929%3Fui%3Dde-DE%26amp%3Brs%3Dde-DE%26amp%3Bad%3DDE%26amp%3BfromAR%3D4%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehere%3C%2FA%3E%20and%20came%20up%20with%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DXLOOKUP(Table1!%20EJ3%3B%20accounts!A%3AA%3B%20XLOOKUP(Table1!%20GD3%3B%20accounts!G%3AG%3B%20XLOOKUP(%22SHOULD%20VZ%20HK%22%3B%20accounts!F%3AF%3B%20accounts!C%3AC)))%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ebut%20this%20gives%20me%20back%20an%20error%20and%20I%20dont%20understand%20why.%20Please%20help!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20you%20have%20solutions%20with%20MATCH%20or%20INDEX%20that%20would%20be%20faster%20than%20my%20existing%20LOOKUP%2C%20please%20don't%20hesitate%20to%20post%20some%20ideas.%20Thank%20you%20very%20much!%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%22Bildschirmfoto%202021-04-17%20um%2018.04.30.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F273538iBF35CBC47DE4E98D%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Bildschirmfoto%202021-04-17%20um%2018.04.30.png%22%20alt%3D%22Screenshot%202021-04-17%20at%2018.04.30.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%E2%80%83%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%E2%80%83%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2276926%22%20slang%3D%22de-DE%22%3E%3CLINGO-LABEL%3EBI%20%26amp%3B%20Data%20Analysis%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%20on%20Mac%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2276979%22%20slang%3D%22de-DE%22%3ERe%3A%20LOOKUP%20to%20XLOOKUP%20Migration%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2276979%22%20slang%3D%22de-DE%22%3EHi%20Hans%2C%20thank%20you%2C%20I%20corrrected%20it%20in%20the%20message.%20I%20forgot%20to%20change%20that%20for%20this%20message..%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2277390%22%20slang%3D%22de-DE%22%3ERe%3A%20LOOKUP%20to%20XLOOKUP%20Migration%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2277390%22%20slang%3D%22de-DE%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%3BThank%20you%20very%20much%20Sergei!!!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20converted%20the%20table%20into%20a%20structured%20table%20and%20was%20able%20to%20implement%20your%20suggestion%20with%20some%20slight%20changes%20%2F%20help%20from%20%3CA%20href%3D%22https%3A%2F%2Fsupport.microsoft.com%2Fen-us%2Foffice%2Fusing-structured-references-with-excel-tables-f5ed2452-2337-4f71-bed3-c8ae6d2b276e%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Ehere%3C%2FA%3E%20.%20It%20goes%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DLET(n%3B%20(COUNTA(Tabelle1%5BDatum%5D))%3B%0AXLOOKUP(1%3B1%2F%0A(Tabelle1%5B%5B%23Headers%5D%3B%5BDatum%5D%5D%3AINDEX(Tabelle1%5BDatum%5D%3B%20n)%20%26gt%3B%3D%20%5B%40DatumAnschreiben%5D)%2F%0A(Tabelle1%5B%5B%23Headers%5D%3B%5BKonto%5D%5D%3AINDEX(Tabelle1%5BKonto%5D%3B%20n)%20%3D%20%5B%40NameKonto%5D)%2F%0A(Tabelle1%5B%5B%23Headers%5D%3B%5BBetreff%5D%5D%3AINDEX(Tabelle1%5BBetreff%5D%3B%20n)%20%3D%20%22SOLL%20VZ%20NK%22)%3B%0A(Tabelle1%5B%5B%23Headers%5D%3B%5BBetrag%5D%5D%3AINDEX(Tabelle1%5BBetrag%5D%3B%20n))))%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWeirdly%2C%20I%20couldn't%20select%20the%20cells%20with%20the%20mouse%2C%20I%20had%20to%20type%20it.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20calculation%20is%20a%20bit%20faster%2C%20I'd%20say%20by%2020%25.%20But%20I%20did%20some%20other%20simplifications%2C%20so%20it's%20hard%20to%20say...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EGreetings%20from%20the%20Morsum%2C%20Island%20of%20Sylt%2C%20Germany!!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Hello! I am currently using the following LOOKUP formula for my real estate managment spreadsheet

 

=LOOKUP(2;1/(Konten!$A:$A>=$EJ$3)/(Konten!$G:$G=$GD4)/(Konten!$F:$F="SOLL VZ HK");(Konten!$C:$C))

 

to look for a date in row Konten!A:A smaller than the date given in $EJ$3 under the condition that

 

  1. it matches the given account $GD4 with row Konten!$G:$G and 
  2. it machtes the given category name "SOLL VZ HK" with row Konten!$F:$F

to return the found value in Konten!$C:$C.

 

For instance: On April 17, 2021 ($EJ$3) for the account "Ly1.OGre Miramar Privat" ($GD4) it returns the value  75,81 which is the the value for April, 1, 2021 (april fools!) and the closest to  April 17, 2021. I would always need the value of the date one instance earlier than the given date.

 

In the desparate need to speed up my spreadsheet with 16k rows of data (it takes over 1 minute to calculate) I wanted to speed things up and translate my LOOKUP formula into a XLOOKUP. I thought I would need a nested XLOOKUP similiar to  Example Nr. 5 in here and came up with 

 

=XLOOKUP(Tabelle1!EJ3;Konten!A:A;XLOOKUP(Tabelle1!GD3;Konten!G:G;XLOOKUP("SOLL VZ HK";Konten!F:F;Konten!C:C)))

 

but this gives me back an error and I dont understand why. Please help!

 

If you have solutions with MATCH or INDEX that would be faster than my existing LOOKUP, please don't hesitate to post some ideas. Thank you very much!

 

Bildschirmfoto 2021-04-17 um 18.04.30.png

 

 

9 Replies
Hi,
Did you see that you mix the German XVERWEIS and the English XLOOKUP ?
-Hans
best response confirmed by daejoum (New Contributor)
Solution

@daejoum 

I'd try to use dynamic ranges instead like

=LOOKUP(2,1/
    (Konten!$A$1:INDEX(Konten!$A:$A, COUNTA(Konten!$A:$A))>=$EJ$3)/
    (Konten!$G$1:INDEX(Konten!$G:$G, COUNTA(Konten!$A:$A))=$GD4)/
    (Konten!$F$1:INDEX(Konten!$F:$F, COUNTA(Konten!$A:$A))="SOLL VZ HK"),
    (Konten!$C$1:INDEX(Konten!$C:$C, COUNTA(Konten!$A:$A)))
)

or, to simplify a bit

=LET(n, COUNTA(Konten!$A:$A),
LOOKUP(2,1/
    (Konten!$A$1:INDEX(Konten!$A:$A, n ) >= $EJ$3)/
    (Konten!$G$1:INDEX(Konten!$G:$G, n ) =  $GD4)/
    (Konten!$F$1:INDEX(Konten!$F:$F, n ) =  "SOLL VZ HK"),
    (Konten!$C$1:INDEX(Konten!$C:$C, n ))
)

Even better if you convert your range into structured table.

 

In general I'm not sure that XLOOKUP is faster than LOOKUP.  In any case, since you have mix of exact and approximate criteria, I guess XLOOKUP shall be used the same way

=LET(n, COUNTA(Konten!$A:$A),
XLOOKUP(1,1/
    (Konten!$A$1:INDEX(Konten!$A:$A, n ) >= $EJ$3)/
    (Konten!$G$1:INDEX(Konten!$G:$G, n ) =  $GD4)/
    (Konten!$F$1:INDEX(Konten!$F:$F, n ) =  "SOLL VZ HK"),
    (Konten!$C$1:INDEX(Konten!$C:$C, n ))
)

As for the second formula, in example second XLOOKUP returns reference on the column (see third parameter). In your formula

=XLOOKUP(Tabelle1!EJ3;
   Konten!A:A;
   XVERWEIS(Tabelle1!GD3;
            Konten!G:G;
            XVERWEIS("SOLL VZ HK";
                     Konten!F:F;
                     Konten!C:C)
))

nested XLOOKUP returns reference on the cell where array is expected.

Hi Hans, thank you, I corrrected it in the message. I forgot to change that for this message..

@Sergei Baklan Thank you very much Sergei!!!

 

I converted the table into a structured table and was able to implement your suggestion with some slight changes / help from here . It goes:

 

 

=LET(n; (COUNTA(Tabelle1[Datum]));
XLOOKUP(1;1/
(Tabelle1[[#Headers];[Datum]]:INDEX(Tabelle1[Datum]; n) >= [@DatumAnschreiben])/
(Tabelle1[[#Headers];[Konto]]:INDEX(Tabelle1[Konto]; n) = [@NameKonto])/
(Tabelle1[[#Headers];[Betreff]]:INDEX(Tabelle1[Betreff]; n) = "SOLL VZ NK");
(Tabelle1[[#Headers];[Betrag]]:INDEX(Tabelle1[Betrag]; n))))

 

 

Weirdly, I couldn't select the cells with the mouse, I had to type it.

 

The calculation is a bit faster, I'd say by 20%. But I also did some other simplifications, so it is hard to say...

 

Greetings from the Morsum, Island of Sylt, Germany!!

 

 

 

 

 

 

@daejoum 

If you convereted range to table same formula will be much simplier:

XLOOKUP(1;1/
  (Tabelle1[Datum] >= [@DatumAnschreiben])/
  (Tabelle1[Konto] = [@NameKonto])/
  (Tabelle1[Betreff] = "SOLL VZ NK");
  (Tabelle1[Betrag])
)

And I'd try instead

INDEX(FILTER(Tabelle1[Betrag];
  (Tabelle1[Datum]   >= [@DatumAnschreiben])*
  (Tabelle1[Konto]   = [@NameKonto])*
  (Tabelle1[Betreff] = "SOLL VZ NK")
);1)

perhaps it gives better result. INDEX() here is to return first element if FILTER() finds more than one which meets criteria.

@Sergei Baklan 

@(FILTER(Tabelle1[Betrag];
  (Tabelle1[Datum]   >= [@DatumAnschreiben])*
  (Tabelle1[Konto]   = [@NameKonto])*
  (Tabelle1[Betreff] = "SOLL VZ NK")
 )

should do the same job, but perhaps that is a little too cryptic?

@Peter Bartholomew 

Exactly, but I do not rely on "@" and prefer to use straightforward INDEX(). 

Back to XLOOKUP(), copy/pasting from LOOKUP() I forgot to remove division, this variant

XLOOKUP(1;
  (Tabelle1[Datum] >= [@DatumAnschreiben])*
  (Tabelle1[Konto] = [@NameKonto])*
  (Tabelle1[Betreff] = "SOLL VZ NK");
  (Tabelle1[Betrag])
)

It does the same job as FILTER() but I'm not sure if any difference from performance point of view.

@Sergei Baklan 

Eventually one settles to a preferred style but I rather like exploring options.

image.png

(i) Concise but cryptic, (ii) basic, (iii) concealed

 

On the timing issues, my first instinct was to back XLOOKUP since it is only looking for the first occurrence.  Yet, in reality, I suspect the entire array of criteria is evaluated before XLOOKUP is called, then XLOOKUP is faced with an unsorted list so further processing is required.

 

Added note: Over 100,000 cells XLOOKUP was noticeably faster (about 30% say) but the variability from run to run was greater than the differences between methods.

@Peter Bartholomew 

Interesting. Tried to test as well (300 000 raw data x 1000 table with formulas)

image.png

Couple of each test, didn't see big difference between attempts. INDEX/MATCH works. INDEX/XMATCH gives the same, didn't include here.