Professional Documents
Culture Documents
Data Analytics Lab 3
Data Analytics Lab 3
Data Analytics Lab 3
VLOOKUP, HLOOKUP, XLOOKUP, COUNT, and COUNTA are functions in Microsoft Excel that help
users perform various tasks related to data lookup and counting.
Contents
1.VLOOKUP (Vertical Lookup):...............................................................................................................1
2.HLOOKUP (Horizontal Lookup):..........................................................................................................2
3. XLOOKUP:..........................................................................................................................................3
4. COUNT:..............................................................................................................................................4
5. COUNTA:............................................................................................................................................5
- `lookup_value`: The value you want to look for in the first column of the table.
- `table_array`: The table range in which you want to search for the lookup value.
- `col_index_num`: The column number of the value you want to return (from the same row).
Suppose you have a table with product IDs, product names, and prices as follows:
You want to find the price of the product with ID 1002. You can use the VLOOKUP function as
follows:
Let's break down the VLOOKUP function:
- `lookup_value`: The value you want to look for in the first column of the table, in this case, 1002.
- `table_array`: The table range in which you want to search for the lookup value, which is A1:C4 in
this example.
- `col_index_num`: The column number of the value you want to return (from the same row), which
is 3 in this case, as we want to return the value from the "Price" column.
- `[range_lookup]`: An optional parameter, TRUE (approximate match) or FALSE (exact match). In this
example, we use FALSE for an exact match.
The function will search for the value 1002 in the first column of the table (column A). It will find this
value in row 3. Then, it will return the value from the same row in the specified column (column 3),
which is $0.50. So the result of the VLOOKUP function in this example will be $0.50, which is the
price of the product with ID 1002.
Sure! Let's use a more detailed example to explain how HLOOKUP works.
Suppose you have a table with months in the first row and sales amounts for each month in different
regions (North, South, East, and West) as follows:
You want to find the sales amount for the month of March in the East region. You can use the
HLOOKUP function as follows:
- `lookup_value`: The value you want to look for in the first row of the table, in this case, "March".
- `table_array`: The table range in which you want to search for the lookup value, which is B1:E5 in
this example.
- `row_index_num`: The row number of the value you want to return (from the same column), which
is 4 in this case, as we want to return the value from the "East" region row.
- `[range_lookup]`: An optional parameter, TRUE (approximate match) or FALSE (exact match). In this
example, we use FALSE for an exact match.
The function will search for the value "March" in the first row of the table (row 1). It will find this
value in column D. Then, it will return the value from the same column in the specified row (row 4),
which is $5,000. So the result of the HLOOKUP function in this example will be $5,000, which is the
sales amount for the month of March in the East region.
3. XLOOKUP:
This is a more versatile function that replaces VLOOKUP and HLOOKUP, allowing you to search for a
value in any column or row. The syntax for XLOOKUP is:
Suppose you have a table with product names in column A, product IDs in column B, and prices in
column C as follows:
You want to find the price of the product with ID 1002. You can use the XLOOKUP function as
follows:
- `lookup_value`: The value you want to look for, in this case, 1002.
- `lookup_array`: The range in which you want to search for the lookup value, which is B2:B4 in this
example.
- `return_array`: The range from which you want to return the value corresponding to the found
lookup value, which is C2:C4 in this case, as we want to return the value from the "Price" column.
The function will search for the value 1002 in the lookup_array (column B). It will find this value in
row 3. Then, it will return the value from the same row in the return_array (column C), which is
$0.50. So the result of the XLOOKUP function in this example will be $0.50, which is the price of the
product with ID 1002.
You can also use XLOOKUP to find the product name for the product with ID 1002 as follows:
This will return "Orange", which is the product name for the product with ID 1002.
4. COUNT:
This function counts the number of cells containing numerical values in a specified range. The syntax
for COUNT is:
Suppose you have a table with test scores for different subjects as follows:
You want to count how many cells have numerical scores in each row. You can use the COUNT
function as follows:
Row 2: `=COUNT(A2:C2)` - This will return 3, as there are three cells with numbers in row 2.
Row 3: `=COUNT(A3:C3)` - This will return 2, as there are two cells with numbers in row 3.
Row 4: `=COUNT(A4:C4)` - This will return 3, as there are three cells with numbers in row 4.
Row 5: `=COUNT(A5:C5)` - This will return 2, as there are two cells with numbers in row 5.
Suppose you have the same table as before, but now you only want to count cells with numbers in
columns A and C:
You can use the COUNT function as follows:
`=COUNT(A2:A5, C2:C5)`
This will return 7, as there are seven cells with numbers in columns A and C (rows 2 to 5).
5. COUNTA:
This function counts the number of non-empty cells in a specified range, including cells containing
text, numbers, or other types of data. The syntax for COUNTA is:
These functions can be very helpful in organizing, analyzing, and managing data in Excel
spreadsheets.
Suppose you have a table with names, ages, and cities as follows:
You want to count how many non-empty cells are in each row. You can use the COUNTA function as
follows:
Row 2: `=COUNTA(A2:C2)` - This will return 3, as there are three non-empty cells in row 2.
Row 3: `=COUNTA(A3:C3)` - This will return 2, as there are two non-empty cells in row 3.
Row 4: `=COUNTA(A4:C4)` - This will return 2, as there are two non-empty cells in row 4.
Row 5: `=COUNTA(A5:C5)` - This will return 2, as there are two non-empty cells in row 5.
`=COUNTA(A2:A5, C2:C5)`
This will return 4, as there are four non-empty cells in columns A and C (rows 2 to 5).