Aladin Akyurek
MrExcel MVP
- Joined
- Feb 14, 2002
- Messages
- 85,210
Quoted from: http://www.mrexcel.com/board2/viewtopic.php?t=87050
Both formulas use a sorted built-in table. The LOOKUP formula invokes binary search, the VLOOKUP formula linear search as determined by the match-type = 0. Therefore the LOOKUP formula will be faster.
How do VLOOKUP, LOOKUP, INDEX/MATCH perform when all invoke binary search?
Before proceeding further, one thing must be noted. Using binary search formulas with sortedtextrequires caution. To see this, enter in B14 the following:
Voyage au bout de la nuit
The LOOKUP formula happily returns 295, while the VLOOKUP formula with match-type set to 0 errors out.
=VLOOKUP(B14,{"Deluxe Tour",128;"Jungle River Safari",88;"My Generation Tour Adult Only",128;"Power Boat Jeep Rental",295},2,1)
would behave like the LOOKUP formula.
This cautionary note does not apply to the use of BigNum/BigStr as lookup values in formulas which invoke binary search in order to determine last numeric/text values in ranges of interest.
How about performance differences?
What follows compares the following sets of formulas:
[1]
=VLOOKUP(B7,AccList!$F$2:$H$9978,3,1)
=VLOOKUP(B7,AccList!$F$2:$L$9978,7,1)
[2]
=LOOKUP(B7,AccList!$F$2:$F$9978,AccList!$H$2:$H$9978)
=LOOKUP(B7,AccList!$F$2:$F$9978,AccList!$L$2:$L$9978)
[3]
=INDEX(AccList!$H$2:$H$9978,MATCH(B7,AccList!$F$2:$F$9978,1))
=INDEX(AccList!$L$2:$L$9978,MATCH(B7,AccList!$F$2:$F$9978,1))
[4]
=INDEX(AccList!$H$2:$H$9978,H7)
=INDEX(AccList!$L$2:$L$9978,H7)
=MATCH(B7,AccList!$F$2:$F$9978,1)
which is in H7.
As is clear, the lookup table is in AccListF2:L9978. Column F houses text-formatted account-numbers and the table is sorted in ascending order on F.
Each formula is copied to 6255 cells.
The figures are averages of 5 runs.
formula 1:
=VLOOKUP(B14,{"Deluxe Tour",128;"Jungle River Safari",88;"My Generation Tour Adult Only",128;"Power Boat Jeep Rental",295},2,0)
formula 2:
=LOOKUP(B14,{"Deluxe Tour","Jungle River Safari","My Generation Tour Adult Only","Power Boat Jeep Rental";128,88,128,295})
i've often wondered how these two would perform next to each other in like conditions, one syntax to another. any idea aladin?
_________________
Regards,
Zack
Both formulas use a sorted built-in table. The LOOKUP formula invokes binary search, the VLOOKUP formula linear search as determined by the match-type = 0. Therefore the LOOKUP formula will be faster.
How do VLOOKUP, LOOKUP, INDEX/MATCH perform when all invoke binary search?
Before proceeding further, one thing must be noted. Using binary search formulas with sortedtextrequires caution. To see this, enter in B14 the following:
Voyage au bout de la nuit
The LOOKUP formula happily returns 295, while the VLOOKUP formula with match-type set to 0 errors out.
=VLOOKUP(B14,{"Deluxe Tour",128;"Jungle River Safari",88;"My Generation Tour Adult Only",128;"Power Boat Jeep Rental",295},2,1)
would behave like the LOOKUP formula.
This cautionary note does not apply to the use of BigNum/BigStr as lookup values in formulas which invoke binary search in order to determine last numeric/text values in ranges of interest.
How about performance differences?
What follows compares the following sets of formulas:
[1]
=VLOOKUP(B7,AccList!$F$2:$H$9978,3,1)
=VLOOKUP(B7,AccList!$F$2:$L$9978,7,1)
[2]
=LOOKUP(B7,AccList!$F$2:$F$9978,AccList!$H$2:$H$9978)
=LOOKUP(B7,AccList!$F$2:$F$9978,AccList!$L$2:$L$9978)
[3]
=INDEX(AccList!$H$2:$H$9978,MATCH(B7,AccList!$F$2:$F$9978,1))
=INDEX(AccList!$L$2:$L$9978,MATCH(B7,AccList!$F$2:$F$9978,1))
[4]
=INDEX(AccList!$H$2:$H$9978,H7)
=INDEX(AccList!$L$2:$L$9978,H7)
=MATCH(B7,AccList!$F$2:$F$9978,1)
which is in H7.
As is clear, the lookup table is in AccListF2:L9978. Column F houses text-formatted account-numbers and the table is sorted in ascending order on F.
Each formula is copied to 6255 cells.
The figures are averages of 5 runs.
All With BS MrExcel.xls | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | |||
1 | FastExcelWorkBookProfile | Version2.0Build434 | |||||||||
2 | WorkBookSummary | ||||||||||
3 | CalcTime(Millisec) | % | MicroSecs | Range | Total | ||||||
4 | Const | Formula | ReCalc | FullCalc | Volatile | /Formula | Mem(K) | Mem(K) | |||
5 | [1]VLOOKUP | 94,935 | 12,522 | 0.2 | 115.6 | 0.2% | 9.2 | 2,071 | 2,136 | ||
6 | [2]LOOKUP | 94,935 | 12,522 | 0.2 | 109.7 | 0.2% | 8.8 | 2,119 | 2,208 | ||
7 | [3]INDEX/MATCH(a) | 94,935 | 12,522 | 0.2 | 118.2 | 0.2% | 9.4 | 2,195 | 2,260 | ||
8 | [4]INDEX/MATCH(b) | 94,935 | 18,783 | 0.2 | 91.9 | 0.3% | 4.9 | 2,319 | 2,406 | ||
9 | |||||||||||
FastXL |