The following spreadsheet demonstrates a very odd behaviour of Google Spreadsheets Lookup functions. I've used these functions many times without any problem. Can anyone confirm it happens on their side as well?
Example doc: https://docs.google.com/spreadsheets/d/16lRQ72K28CtObY_ChzpNQUVTl_EgbjEyRcpP5QOZKzE/edit?usp=sharing
If is_sorted is set to TRUE or omitted, and the first column of the range is not in sorted order, an incorrect value might be returned. If VLOOKUP doesn't appear to be giving correct results, check that the last argument is set to FALSE . If the data is sorted and you need to optimize for performance, set it to TRUE .
The above Hlookup formula searches across the first row for the key “Mar” in this range and returns the value from the second row, i.e. 4. See the column Index in Hlookup, i.e. 2 (second row). This way you can use the Vlookup and Hlookup Combination in Google Sheets.
XLOOKUP is alternative to VLOOKUP, HLOOKUP, and INDEX. While these three functions will remain in Excel, many users will find XLOOKUP to be simpler, more intuitive, and even more powerful.
By Default VLOOKUP
does approximate matches. @Pnuts explained that the desired result is not being returned in every case because the the search is binary.
Excels optional parameter for VLOOKUP
is called range_lookup and quote:
range_lookup Optional. A logical value that specifies whether you want VLOOKUP to find an exact match or an approximate match:
If range_lookup is either TRUE or is omitted, an exact or approximate match is returned. If an exact match is not found, the next largest value that is less than lookup_value is returned.
IMPORTANT If range_lookup is either TRUE or is omitted, the values in the first column of table_array must be placed in ascending sort order; otherwise, VLOOKUP might not return the correct value.
For more information, see Sort data in a range or table.
If range_lookup is FALSE, the values in the first column of table_array do not need to be sorted.
If the range_lookup argument is FALSE, VLOOKUP will find only an exact match. If there are two or more values in the first column of table_array that match the lookup_value, the first value found is used. If an exact match is not found, the error value #N/A is returned.
Google's optional parameter for VLOOKUP
is called is_sorted and quote:
is_sorted - [OPTIONAL - TRUE by default] - Indicates whether the column to be searched (the first column of the specified range) is sorted.
If is_sorted is TRUE or omitted, the nearest match (less than or equal to the search key) is returned. If all values in the search column are greater than the search key, #N/A is returned.
If is_sorted is set to TRUE or omitted, and the first column of the range is not in sorted order, an incorrect value might be returned.
If is_sorted is FALSE, only an exact match is returned. If there are multiple matching values, the content of the cell corresponding to the first value found is returned, and #N/A is returned if no such value is found.
If you need exact matching with VLOOKUP
just add FALSE
in the optional parameter to force the lookup of exact matching. If you are using the MATCH
then add a 0.
So the formulas for your spreadsheet should look like:
=VLOOKUP(A2,A1:E13,5,FALSE)
=VLOOKUP("n1-standard-2",A1:E13,5,FALSE)
=MATCH(A2,A1:A13,0)
=MATCH("n1-standard-2",A1:A13,0)
=HLOOKUP(A1,A1:E13,5,FALSE)
=HLOOKUP("n1-standard-1",A1:E13,5,FALSE)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With