Module: M3-R5: Python Programming
Chapter: Ch1 Computer Intro
The Lookup and Reference functions in LibreOffice Calc and Excel are used to search for data within a table or range and return relevant information. These include functions like VLOOKUP, HLOOKUP, INDEX, MATCH, and the newer XLOOKUP.
Purpose: Searches for a value in the first column of a table and returns data from another column in the same row.
| Product ID | Product Name | Price |
|---|---|---|
| 101 | Keyboard | 800 |
| 102 | Mouse | 500 |
| 103 | Monitor | 7000 |
| 104 | Printer | 4500 |
Formula: =VLOOKUP(103;A2:C5;3;0)
Explanation: Looks up 103 in column A and returns value from column 3 (Price) → 7000.
Purpose: Searches for a value in the top row and returns data from another row in the same column.
| A | B | C | D | |
|---|---|---|---|---|
| Product ID | 101 | 102 | 103 | 104 |
| Price | 800 | 500 | 7000 | 4500 |
Formula: =HLOOKUP(103;B1:E2;2;0)
Result: 7000
Purpose: Returns the value of a cell in a specific row and column of a range.
| Name | Department | Salary |
|---|---|---|
| John | HR | 35000 |
| Mary | IT | 40000 |
| Raj | Finance | 42000 |
Formula: =INDEX(C2:C4;2)
Result: 40000
Explanation: Returns 2nd value from the Salary column.
Purpose: Returns the position of a lookup value in a range.
Find the position of “Raj” in the Name column.
Formula: =MATCH("Raj";A2:A4;0)
Result: 3
Explanation: “Raj” appears in the 3rd row of the range A2:A4.
Purpose: Used together, these functions perform flexible lookups (similar to VLOOKUP, but more powerful).
Get Salary for “Mary”.
Formula: =INDEX(C2:C4;MATCH("Mary";A2:A4;0))
Result: 40000
Purpose: A modern replacement for VLOOKUP and HLOOKUP. It searches for a value and returns a corresponding value from another range, supporting both vertical and horizontal lookups.
| Product | Price |
|---|---|
| Keyboard | 800 |
| Mouse | 500 |
| Monitor | 7000 |
| Printer | 4500 |
Formula: =XLOOKUP("Monitor";A2:A5;B2:B5)
Result: 7000
| Function | Purpose | Example Formula |
|---|---|---|
| VLOOKUP | Vertical search by first column | =VLOOKUP(103;A2:C5;3;0) |
| HLOOKUP | Horizontal search by first row | =HLOOKUP(103;B1:E2;2;0) |
| INDEX | Returns cell value by row/column number | =INDEX(C2:C4;2) |
| MATCH | Finds position of lookup value | =MATCH("Raj";A2:A4;0) |
| INDEX + MATCH | Combined flexible lookup | =INDEX(C2:C4;MATCH("Mary";A2:A4;0)) |
| XLOOKUP | New flexible lookup function | =XLOOKUP("Monitor";A2:A5;B2:B5) |
Lookup and reference functions are essential tools for managing and retrieving data efficiently. INDEX + MATCH and XLOOKUP offer advanced flexibility, making them ideal for modern data analysis in LibreOffice Calc.