Fast Lookups in Excel
Thursday, April 21st, 2011How do you get excel to quickly perform 160,000 lookups against 160,000 different unique records and get an exact match, for a total of up to 25,600,000,000 different operations?
Basically there is a fast way to do this that quickly produces results in a minute or so - and a slow way to do this that checks all combinations and could take hours.
-
The fast way is to use IF formula to check if index match found an exact match on a sorted table, if it did not then don’t use the result, if it did then use the result.
=IF(A3=INDEX(’Rate Table’!$B$1:$B$145390,MATCH(O3,’Rate Table’!$B$1:$B$145390)),INDEX(’Rate Table’!$A$1:$A$145390,MATCH(A3,’Rate Table’!$B$1:$B$145390)),”NONE”)
Why would you need to do this?
Maybe you have a huge list of names and you want to look up their phone number in a directory, or vice versa.
In our case we were analyzing the costs of 160,000 different phone calls against different rate plans. Each call could be billed at any of 160,000 different rate plans. (While consumer rates are simple - wholesale rates are quite complex - all numbers starting with the NPA NXX 212-555 may have a different rate from all numbers starting with 212-556.)
You want excel to look at the call and see where the call was made to and what the rate should be. For example a call is to the 212-555 NPA NXX. You therefore look up on the rate table what the rate is for calls to the 212-555 NPA NXX. You then have excel do this for every call you make.
