I'm trying to avoid the redundancy of calculating the same index as many times as there are records, so should I pre-calculate the index with MATCH in a hidden cell above my table?
It is also worth noting that while my tables are not going to be massive, they are not going to be small either. Probably there are going to be about 6 tables each with one or two VLOOKUPS (full column) with a total count of records in the hundreds.
More precisely, I'm going to create a set of tables in Excel and I'm going to be emulating the goodies of a proper relational database using the VLOOKUP function to get a value of a related table, but I will make use of MATCH function to get the the index of the column I want by it's header. The following is the actual formula I will use:
=VLOOKUP([@ForeignKey],RelatedTable,MATCH(RelatedTable[[#Headers],[ItemName]],RelatedTable[#Headers],0),FALSE)
'Broken down by parameters VLOOKUP( Lookup_value := [@ForeignKey] Table_array := RelatedTable Col_index_num := 'Return of MATCH MATCH( Lookup_value := RelatedTable[[#Headers],[ItemName]] Lookup_array := RelatedTable[#Headers] Match_type := 0 'Exact Match Range_lookup := FALSE 'Exact Match
EDIT:
The first table is the one with the primary key. The last two are either of the two examples I'm referring to.
Table_Products ╔════╦════════╦═══════════════╦═══════════╗ ║ ║ A ║ B ║ C ║ ╠════╬════════╬═══════════════╬═══════════╣ ║ 1 ║ ItemID ║ ItemName ║ ItemPrice ║ ╠════╬════════╬═══════════════╬═══════════╣ ║ 2 ║ 1 ║ Stylus ║ $ 25.00 ║ ╠════╬════════╬═══════════════╬═══════════╣ ║ 3 ║ 2 ║ Mech Keyboard ║ $ 120.00 ║ ╠════╬════════╬═══════════════╬═══════════╣ ║ 4 ║ 3 ║ Monitor ║ $ 750.00 ║ ╚════╩════════╩═══════════════╩═══════════╝ Table_Transactions EITHER LIKE THIS ╔════╦════════╦════════╦═════╦═══════════════════════╗ ║ ║ A ║ B ║ C ║ D ║ ╠════╬════════╬════════╬═════╬═══════════════════════╣ ║ 1 ║ CustID ║ ItemID ║ Qty ║ ItemName ║ ╠════╬════════╬════════╬═════╬═══════════════════════╣ ║ 2 ║ 101 ║ 3 ║ 1 ║ VLOOKUP(,,Match(,,),) ║ ╠════╬════════╬════════╬═════╬═══════════════════════╣ ║ 3 ║ 102 ║ 3 ║ 2 ║ ... ║ ╠════╬════════╬════════╬═════╬═══════════════════════╣ ║ 4 ║ 103 ║ 3 ║ 1 ║ ... ║ ╠════╬════════╬════════╬═════╬═══════════════════════╣ ║ 5 ║ 104 ║ 2 ║ 3 ║ ... ║ ╠════╬════════╬════════╬═════╬═══════════════════════╣ ║ 6 ║ 105 ║ 1 ║ 8 ║ ... ║ ╠════╬════════╬════════╬═════╬═══════════════════════╣ ║ 7 ║ 106 ║ 2 ║ 2 ║ ... ║ ╠════╬════════╬════════╬═════╬═══════════════════════╣ ║ 8 ║ 107 ║ 2 ║ 1 ║ ... ║ ╠════╬════════╬════════╬═════╬═══════════════════════╣ ║ 9 ║ 108 ║ 2 ║ 2 ║ ... ║ ╠════╬════════╬════════╬═════╬═══════════════════════╣ ║ 10 ║ 109 ║ 1 ║ 4 ║ ... ║ ╠════╬════════╬════════╬═════╬═══════════════════════╣ ║ 11 ║ 110 ║ 2 ║ 16 ║ ... ║ ╚════╩════════╩════════╩═════╩═══════════════════════╝ OR LIKE THIS (D1 cell is NOT part of the table) ╔════╦════════╦════════╦═════╦═════════════════╗ ║ ║ A ║ B ║ C ║ D ║ ╠════╬════════╬════════╬═════╬═════════════════╣ ║ 1 ║ ║ ║ ║ Match(,,) ║ ╠════╬════════╬════════╬═════╬═════════════════╣ ║ 2 ║ CustID ║ ItemID ║ Qty ║ ItemName ║ ╠════╬════════╬════════╬═════╬═════════════════╣ ║ 3 ║ 101 ║ 3 ║ 1 ║ VLOOKUP(,,D$1,) ║ ╠════╬════════╬════════╬═════╬═════════════════╣ ║ 4 ║ 102 ║ 3 ║ 2 ║ ... ║ ╠════╬════════╬════════╬═════╬═════════════════╣ ║ 5 ║ 103 ║ 3 ║ 1 ║ ... ║ ╠════╬════════╬════════╬═════╬═════════════════╣ ║ 6 ║ 104 ║ 2 ║ 3 ║ ... ║ ╠════╬════════╬════════╬═════╬═════════════════╣ ║ 7 ║ 105 ║ 1 ║ 8 ║ ... ║ ╠════╬════════╬════════╬═════╬═════════════════╣ ║ 8 ║ 106 ║ 2 ║ 2 ║ ... ║ ╠════╬════════╬════════╬═════╬═════════════════╣ ║ 9 ║ 107 ║ 2 ║ 1 ║ ... ║ ╠════╬════════╬════════╬═════╬═════════════════╣ ║ 10 ║ 108 ║ 2 ║ 2 ║ ... ║ ╠════╬════════╬════════╬═════╬═════════════════╣ ║ 11 ║ 109 ║ 1 ║ 4 ║ ... ║ ╠════╬════════╬════════╬═════╬═════════════════╣ ║ 12 ║ 110 ║ 2 ║ 16 ║ ... ║ ╚════╩════════╩════════╩═════╩═════════════════╝