EXCEL: formula to extract data from a table

2 min read 28-08-2024
EXCEL: formula to extract data from a table


This article will provide you with a comprehensive guide on extracting data from a table in Excel using formulas. We will cover the common scenarios and provide step-by-step instructions to help you achieve your desired results.

Understanding the Problem

You have a table in Excel, and you want to find a specific value within a defined range. Once you locate the value, you want to extract the corresponding value from a specific column (in this case, column G).

Using the INDEX and MATCH Functions

The combination of the INDEX and MATCH functions is a powerful way to extract data based on a lookup value. Here's how it works:

  1. MATCH function: The MATCH function searches for a specific value within a range and returns the relative position of that value.

  2. INDEX function: The INDEX function returns a value from a specified range based on its row and column position.

Here's the formula using INDEX and MATCH:

=INDEX(G2:G4,MATCH(lookup_value,A2:F4,0))

Explanation:

  • lookup_value: This is the value you want to find within the table.
  • A2:F4: This is the range where you want to search for the lookup_value.
  • G2:G4: This is the range from which you want to extract the corresponding value.
  • 0: This argument specifies an exact match for the lookup_value.

Example:

Let's say your table looks like this:

A B C D E F G
Apple Banana Orange Grape Kiwi Mango 10
Pear Strawberry Blueberry Raspberry Watermelon Pineapple 20
Cherry Peach Apricot Plum Pomegranate Fig 30

If you want to find the value in column G that corresponds to "Orange", you would use the following formula:

=INDEX(G2:G4,MATCH("Orange",A2:F4,0))

This formula will return the value 10 because "Orange" is located in the first row of the table, and the first value in column G is 10.

Using the XLOOKUP Function (Excel 365)

If you are using Excel 365, you can use the XLOOKUP function for a more streamlined solution. This function combines both the searching and extraction steps in one formula.

Here's the formula using XLOOKUP:

=XLOOKUP(lookup_value,A2:F4,G2:G4)

Explanation:

  • lookup_value: This is the value you want to find within the table.
  • A2:F4: This is the range where you want to search for the lookup_value.
  • G2:G4: This is the range from which you want to extract the corresponding value.

Example:

Using the same table as before, you would use the following formula to find the value in column G corresponding to "Strawberry":

=XLOOKUP("Strawberry",A2:F4,G2:G4)

This formula will return the value 20 because "Strawberry" is located in the second row of the table, and the second value in column G is 20.

Choosing the Right Approach

The choice between the INDEX/MATCH combination and XLOOKUP depends on your preference and your version of Excel.

  • INDEX/MATCH: This method is a classic approach and works across all Excel versions. It offers flexibility for more complex scenarios with multiple criteria.
  • XLOOKUP: This method is simpler and more efficient for straightforward lookup operations in Excel 365. It's a great option for new users who prefer a concise formula.

Conclusion

This article has explored two methods for extracting data from a table in Excel. You can choose the method that best suits your needs and your version of Excel. By using these formulas, you can easily extract specific data based on lookup values and streamline your data analysis workflow.