Introduction

Data integration is a critical aspect of working with spreadsheets, especially when dealing with diverse data sources or multiple datasets. In this article, we'll explore an efficient method for data integration using the HSTACK and XLOOKUP functions. These two powerhouse functions can help you merge data from different sources seamlessly.

Understanding the Challenge

Imagine you have data in multiple columns or datasets that you want to integrate into a single, cohesive dataset. This task can be daunting if done manually, involving copying and pasting or using complex formulas. However, with Excel's HSTACK and XLOOKUP functions, you can simplify the data integration process and save a significant amount of time.

Sample Data

In the screenshots below, we've got the sheets where we are going to perform the data integration and the source data.

Source data

Table data

The XLOOKUP Function

The XLOOKUP function is a versatile tool for searching and retrieving data from a given range based on specified criteria. In our case, we will use XLOOKUP to fetch data from different columns or datasets and then stack them horizontally.

Syntax: XLOOKUP(lookup_value, lookup_array, return_array)

lookup_value: The value to search for.
lookup_array: The range to search within.
return_array: The range to retrieve data from.

The HSTACK Function

Now, let's introduce the HSTACK function. This function enables stacking of data horizontally, creating a unified dataset by placing the results of different XLOOKUP functions side by side.

Syntax: HSTACK(range1, range2, ...)

range1, range2, ...: Multiple ranges or data sources that you want to stack horizontally.

Efficient Data Integration Formula

In cell B4, execute this formula:

Python
=HSTACK(XLOOKUP(A4:A10,sales[Account Manager],sales[Product]),XLOOKUP(A4:A10,sales[Account Manager],sales[Total Sales £]))

Breakdown of the first XLOOKUP function in the formula: XLOOKUP(A4:A10, sales[Account Manager], sales[Product])

XLOOKUP Function: XLOOKUP(A4:A10,sales[Account Manager],sales[Total Sales £])
The second XLOOKUP function in the formula is essentially the same as the first one, but it returns values from a different column.

In the screenshot below, we have the result of the data integration using HSTACK and XLOOKUP.

Excel

Summary

The formula uses XLOOKUP to search for specific information related to account managers in a sales data table and then stacks the results side by side using the HSTACK function. The result shows a table with account manager names, their corresponding products, and their total sales values. See you in the next tutorial.