搜索
首页专题excelExcel Xlookup vs Vlookup:差异和优势

In this article, we will explore the differences between XLOOKUP, VLOOKUP and HLOOKUP, helping you choose the right function for your data analysis tasks.

If you work with Excel, you probably know how useful the VLOOKUP function is. It allows you to look up a value in a table and return a corresponding value from another column. But did you know that there is a newer and more powerful function called XLOOKUP that can do even more? In this tutorial, we will compare these two functions and see how they differ in syntax, functionality and performance.

VLOOKUP vs. XLOOKUP - syntax comparison

Like the cornerstone of chemistry is the periodic table of elements, the heart of any Excel function is its set of parameters. Let's take a closer look at the arguments of two popular lookup functions to unravel their nuances.

The syntax of the VLOOKUP function looks like this:

VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])

Where:

  • lookup_value - the value to search for.
  • table_array - the entire dataset.
  • col_index_num - the number of the column from which to retrieve the value.
  • range_lookup [optional] - specifies whether to find an approximate match (default - TRUE) or exact match (FALSE).

And the XLOOKUP function has a bit more complex structure:

XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])

Where:

  • lookup_value - the value to search for.
  • lookup_array - the range where to search for the lookup value.
  • return_array - the range from which to return a value.
  • if_not_found [optional] - the value to return if no match is found.
  • match_mode [optional] - controls the type of match such as exact (0 - default), exact match or next smaller (-1), exact match or next larger (1), wildcard (2).
  • search_mode [optional] - specifies the search type such as first to last (1 - default), last to first (-1), binary search ascending (2), binary search descending (-2).

For more detailed explanation of the arguments, please see:

  • XLOOKUP function - syntax
  • VLOOKUP function - syntax

As you can see, both functions need at least three parameters to do their job. But XLOOKUP provides more additional options, making it more powerful and versatile than its VLOOKUP counterpart. Let's break down the main syntax differences in how they work.

Excel Xlookup vs Vlookup:差异和优势

1. Where to search (lookup array vs. table array)

VLOOKUP forces the user to indicate the entire table_array, searching for the lookup value exclusively in the leftmost column. The column to return a value from is determined by the column number in the subsequent argument.

XLOOKUP, in contrast, allows the lookup and return columns to be specified separately. This separation ensures exceptional flexibility - the lookup column can be positioned to the left or right of the return value column.

2. Where to return a value from (return array vs. column number)

VLOOKUP employs a hardcoded index number to denote the return column, creating vulnerability when altering the lookup array structure. Changes like adding or removing columns may easily break your formula.

With XLOOKUP, you supply a range reference for the return array, making it better at handling changes in your source data. Moreover, XLOOKUP can accommodate multiple columns in the return array, a feature requiring two or more different VLOOKUP formulas to achieve.

Excel Xlookup vs Vlookup:差异和优势

3. How to match (match mode vs. range lookup)

The range_lookup argument in VLOOKUP and match_mode in XLOOKUP determine whether the formula seeks an exact or approximate match. While both functions share similar possibilities, XLOOKUP defaults to an exact match, offering a more intuitive default setting. Additionally, XLOOKUP provides an extra option for an approximate match returning the next larger value, without requiring the lookup array to be sorted, as VLOOKUP does.

Match type VLOOKUP XLOOKUP
Exact FALSE or 0 0 or omitted (default)
Approximate (exact or next smaller) TRUE or 1 (default) Needs the lookup column sorted in ascending order. -1
Approximate (exact or next larger) N/A 1
Wildcard FALSE (exact match) 2

4. How to handle missing values (if not found)

In cases where the lookup value is not found, VLOOKUP can only return the standard #N/A! error, potentially causing you to question the formula's accuracy.

By providing the if_not_found argument, XLOOKUP enables you to return a personalized message, such as "The value you are looking for is not found in the database".

Simply put, while VLOOKUP can only say "I can't find it" with an error, XLOOKUP lets you display something specific if it can't find what you're looking for. For example:

=XLOOKUP(F10, B4:B25, C4:C25, "Oops, nothing is found :(")

Excel Xlookup vs Vlookup:差异和优势

5. How to search (search mode)

VLOOKUP always starts searching at the top and stops when it finds the first match.

XLOOKUP introduces the search_mode argument, allowing users to do both first-to-last and last-to-first searches. Also, it lets you leverage binary search methods for faster results in extensive datasets.

For example, in the table below, VLOOKUP can only find the supplier for the first order of a given item, while XLOOKUP can do it for both the first and last orders. Just set search_mode to 1 for the first match and -1 for the last match:

=XLOOKUP(J4, F4:F25, G4:G25, , , -1)

Excel Xlookup vs Vlookup:差异和优势

In summary, XLOOKUP gives more choices and control allowing us to specify different arrays for the lookup and return values, as well as various options for the match mode, search mode, and error handling.

Difference between VLOOKUP and XLOOKUP

The differences in VLOOKUP and XLOOKUP syntax play a crucial role in their performance. Now, let's explore these distinctions in a more detailed manner.

1. Position of lookup column (left lookup)

While VLOOKUP is limited to searching only in the first column in the specified table_array, XLOOKUP can look up values in any column, not just the leftmost one. This means XLOOKUP can easily perform bi-directional lookups without needing any data rearrangement.

As you can notice in the screenshot below, VLOOKUP fails to bring a value from a column (Item) when it's on the right side of the lookup column (Supplier).

=VLOOKUP(E4, A4:B25, 1, FALSE)

XLOOKUP, on the other hand, handles this left-side lookup with ease:

=XLOOKUP(E4, B4:B25, A4:A25)

Excel Xlookup vs Vlookup:差异和优势

2. Return values from multiple columns

VLOOKUP can only return a single value at a time, limiting its efficiency. On the contrary, XLOOKUP can return values from multiple columns in one go. This means you can use a single XLOOKUP formula instead of multiple VLOOKUPs.

For example, if you want to retrieve all details about a particular item, using VLOOKUP requires four separate formulas. You'd supply col_index_num values ranging from 2 (for Region in column B) to 5 (for Supplier in column E):

To get the region:

=VLOOKUP($B$17, $A$4:$E$13, 2, FALSE)

To get the discount:

=VLOOKUP($B$17, $A$4:$E$13, 3, FALSE)

Due to support for dynamic arrays, XLOOKUP simplifies this process, allowing you to fetch all the data with just one formula:

=XLOOKUP(B17, A4:A13, B4:E13)

Excel Xlookup vs Vlookup:差异和优势

3. Search with multiple criteria

XLOOKUP shines at searching for values using multiple criteria without needing extra helper columns, unlike VLOOKUP. For practical examples, please check out:

  • XLOOKUP formula with multiple criteria
  • VLOOKUP with multiple criteria

4. Finding the last occurrence

To locate the last occurrence using VLOOKUP, you would need to reverse the order of your source data. However, with the search_mode parameter, XLOOKUP can get the last instance of the lookup value without any extra moves. For practical examples, please see:

  • XLOOKUP to get the last match

5. Column insertions or deletions

VLOOKUP relies on a static index column number, making it vulnerable to issues when updating the data source or making changes to the column order. XLOOKUP handles such modifications easily, ensuring the formula remains intact.

Excel Xlookup vs Vlookup:差异和优势

6. Size limit for the lookup value

In VLOOKUP, the length of the lookup criteria cannot exceed 255 characters, or you'll get a #VALUE! error. But XLOOKUP imposes no limit on the lookup value’s size. So, if your dataset contains really long strings, XLOOKUP is the solution to avoid errors.

7. Sorting of lookup range

While VLOOKUP demands ascending order sorting for its approximate search, XLOOKUP doesn’t have this limitation, providing adaptability in scenarios where sorting is not possible.

8. Versatility in matching

XLOOKUP stands out for its versatility in matching options offering various choices, such as exact matches, two types of approximate matching (next smaller or next larger), wildcard matches, and even binary searches. In contrast, VLOOKUP has fewer options, limited to exact matches and next smaller in approximate searches.

9. Handling errors

XLOOKUP is better at handling errors or missing values. You can decide what it should show if it can't find the requested value, which VLOOKUP doesn't allow.

10. Efficiency and speed

XLOOKUP is faster and more efficient because it looks only where it needs to (the lookup array and the return array), without wasting time and resources on scanning the entire table like VLOOKUP does.

11. Ease of use

While VLOOKUP has fewer arguments, simplicity in syntax doesn't necessarily equate to ease of use. XLOOKUP’s parameters, such as the lookup array and return array, offer a more intuitive approach compared to VLOOKUP's table array and column index number. This makes XLOOKUP more user-friendly, especially for beginners.

12. Compatibility with Excel versions

This is the only area where VLOOKUP surpasses its counterpart :) While VLOOKUP operates in any version of Excel, XLOOKUP is available only in Microsoft 365, Excel 2021, and Excel for the Web.

These differences highlight XLOOKUP's dynamic and efficient nature, making it a powerful choice over VLOOKUP for various data lookup tasks in Excel.

XLOOKUP vs. VLOOKUP - summary table

The table below outlines the main differences between the XLOOKUP and VLOOKUP functions in Excel. It's a quick guide to help you understand which one might be better for your tasks.

Feature VLOOKUP XLOOKUP
Availability All versions Excel 2021, Excel 365, Excel for the web
Exact match Yes Yes
Approximate matching 1 option (next smaller) 2 options (next smaller or next larger)
Default Approximate match Exact match
Wildcard search Yes Yes
Binary search No Yes
Lookup column needs to be sorted For approximate match For binary search
Limit for a lookup value 255 characters No
Left lookup No Yes
Horizontal lookup (in rows) No Yes
Search in reverse order No Yes
Multiple criteria Complicated, with helper column Easier, without helper column
Return values from multiple columns No Yes
Built-in error handling No Yes
Adding / removing columns may break the formula Yes No

XLOOKUP vs. HLOOKUP

In older versions of Excel, if you wanted to look up data in columns, you'd use VLOOKUP, and for rows, there's HLOOKUP. However, the XLOOKUP function can do both jobs! Let's see how it compares to HLOOKUP.

Excel Xlookup vs Vlookup:差异和优势

1. Search in any row

HLOOKUP can only search in the top row of the table_array, while XLOOKUP can search in any row.

2. Search in both directions

HLOOKUP can only go from left to right, but XLOOKUP can search in both directions. It's like having a double-sided search tool.

3. Matching types and defaults

HLOOKUP defaults to an approximate match and needs the lookup row to be sorted ascending. On the flip side, XLOOKUP defaults to an exact match, which is what you'd usually need in most situations.

All the other differences we talked about between XLOOKUP and VLOOKUP also apply to HLOOKUP. So, XLOOKUP is like a super function in Excel that can find and return values from any table or range with more flexibility, control and features than both older lookup functions combined.

Summing up: While VLOOKUP has been a reliable tool for many years, XLOOKUP now offers a more robust and user-friendly alternative. Its ability to perform both vertical and horizontal lookups, improved syntax, and enhanced error handling make it a preferred choice for all your lookups. If you have access to Excel 365 or 2021, you should definitely give it a try and see how it can elevate your Excel sheets.

Practice workbook for download

XLOOKUP vs. VLOOKUP - differences with examples (.xlsx file)

以上是Excel Xlookup vs Vlookup:差异和优势的详细内容。更多信息请关注PHP中文网其他相关文章!

声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
Excel中的中位公式 - 实际示例Excel中的中位公式 - 实际示例Apr 11, 2025 pm 12:08 PM

本教程解释了如何使用中位功能计算Excel中数值数据中位数。 中位数是中心趋势的关键度量

Google电子表格Countif函数带有公式示例Google电子表格Countif函数带有公式示例Apr 11, 2025 pm 12:03 PM

Google主张Countif:综合指南 本指南探讨了Google表中的多功能Countif函数,展示了其超出简单单元格计数的应用程序。 我们将介绍从精确和部分比赛到Han的各种情况

Excel共享工作簿:如何为多个用户共享Excel文件Excel共享工作簿:如何为多个用户共享Excel文件Apr 11, 2025 am 11:58 AM

本教程提供了共享Excel工作簿,涵盖各种方法,访问控制和冲突解决方案的综合指南。 现代Excel版本(2010年,2013年,2016年及以后)简化了协作编辑,消除了M的需求

如何将Excel转换为JPG-保存.xls或.xlsx作为图像文件如何将Excel转换为JPG-保存.xls或.xlsx作为图像文件Apr 11, 2025 am 11:31 AM

本教程探讨了将.xls文件转换为.jpg映像的各种方法,包括内置的Windows工具和免费的在线转换器。 需要创建演示文稿,安全共享电子表格数据或设计文档吗?转换哟

excel名称和命名范围:如何定义和使用公式excel名称和命名范围:如何定义和使用公式Apr 11, 2025 am 11:13 AM

本教程阐明了Excel名称的功能,并演示了如何定义单元格,范围,常数或公式的名称。 它还涵盖编辑,过滤和删除定义的名称。 Excel名称虽然非常有用,但通常是泛滥的

标准偏差Excel:功能和公式示例标准偏差Excel:功能和公式示例Apr 11, 2025 am 11:01 AM

本教程阐明了平均值的标准偏差和标准误差之间的区别,指导您掌握标准偏差计算的最佳Excel函数。 在描述性统计中,平均值和标准偏差为interinsi

Excel中的平方根:SQRT功能和其他方式Excel中的平方根:SQRT功能和其他方式Apr 11, 2025 am 10:34 AM

该Excel教程演示了如何计算正方根和n根。 找到平方根是常见的数学操作,Excel提供了几种方法。 计算Excel中正方根的方法: 使用SQRT函数:

Google表基础知识:了解如何使用Google电子表格Google表基础知识:了解如何使用Google电子表格Apr 11, 2025 am 10:23 AM

解锁Google表的力量:初学者指南 本教程介绍了Google Sheets的基础,这是MS Excel的强大而多才多艺的替代品。 了解如何轻松管理电子表格,利用关键功能并协作

See all articles

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
3 周前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳图形设置
3 周前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您听不到任何人,如何修复音频
3 周前By尊渡假赌尊渡假赌尊渡假赌
WWE 2K25:如何解锁Myrise中的所有内容
3 周前By尊渡假赌尊渡假赌尊渡假赌

热工具

Atom编辑器mac版下载

Atom编辑器mac版下载

最流行的的开源编辑器

螳螂BT

螳螂BT

Mantis是一个易于部署的基于Web的缺陷跟踪工具,用于帮助产品缺陷跟踪。它需要PHP、MySQL和一个Web服务器。请查看我们的演示和托管服务。

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

功能强大的PHP集成开发环境

EditPlus 中文破解版

EditPlus 中文破解版

体积小,语法高亮,不支持代码提示功能

SecLists

SecLists

SecLists是最终安全测试人员的伙伴。它是一个包含各种类型列表的集合,这些列表在安全评估过程中经常使用,都在一个地方。SecLists通过方便地提供安全测试人员可能需要的所有列表,帮助提高安全测试的效率和生产力。列表类型包括用户名、密码、URL、模糊测试有效载荷、敏感数据模式、Web shell等等。测试人员只需将此存储库拉到新的测试机上,他就可以访问到所需的每种类型的列表。