Google 个电子表格中的错误结果查找函数(vlookup、hlookup、匹配)
Wrong results in Google spreadsheets Lookup functions (vlookup, hlookup, match)
以下电子表格演示了 Google 电子表格查找函数的一个非常奇怪的行为。我已经多次使用这些功能,没有任何问题。任何人都可以确认它也发生在他们这边吗?
示例文档:https://docs.google.com/spreadsheets/d/16lRQ72K28CtObY_ChzpNQUVTl_EgbjEyRcpP5QOZKzE/edit?usp=sharing
默认情况下 VLOOKUP
进行近似匹配。 @Pnuts 解释说,由于搜索是二进制的,因此并非在每种情况下都返回所需的结果。
VLOOKUP
的 Excel 可选参数称为 range_lookup 并引用:
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 的 VLOOKUP
的可选参数称为 is_sorted 并引用:
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.
如果您需要精确匹配VLOOKUP
,只需在可选参数中添加FALSE
以强制查找精确匹配。如果您使用的是 MATCH
然后添加一个 0.
所以电子表格的公式应该如下所示:
=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)
以下电子表格演示了 Google 电子表格查找函数的一个非常奇怪的行为。我已经多次使用这些功能,没有任何问题。任何人都可以确认它也发生在他们这边吗?
示例文档:https://docs.google.com/spreadsheets/d/16lRQ72K28CtObY_ChzpNQUVTl_EgbjEyRcpP5QOZKzE/edit?usp=sharing
默认情况下 VLOOKUP
进行近似匹配。 @Pnuts 解释说,由于搜索是二进制的,因此并非在每种情况下都返回所需的结果。
VLOOKUP
的 Excel 可选参数称为 range_lookup 并引用:
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 的 VLOOKUP
的可选参数称为 is_sorted 并引用:
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.
如果您需要精确匹配VLOOKUP
,只需在可选参数中添加FALSE
以强制查找精确匹配。如果您使用的是 MATCH
然后添加一个 0.
所以电子表格的公式应该如下所示:
=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)