Search functions: RANK, INDEX + MATCH or INDEX + MATCH

00Comment iconComment iconComment iconComment icon

Could there be a better way to search than VLOOKUP? Discover the combination of the INDEX function with MATCH in Excel or spreadsheets!

Writer image

تمت الترجمة بواسطةEditorial

Writer image

تمت المراجعة بواسطةEditorial

Edit Article

RANK function

The RANK function returns the position of a specified value in a dataset.

RANK function syntax

=RANK(value; table_array; [order])

Where:

- value is the value whose ranking will be tested

- table_array is the range where the search will be performed;

- order is a TRUE or FALSE value for ASCENDING or DESCENDING respectively. FALSE will be considered if no value is entered.

Example

productprofitRank
TRANSPARENT PIPING BAG 30CM C/100UN100.001
CELEBRATE CAKE STAND 5UN93.692
PROFESSIONAL SILICONE MAT52.723
WILTON 6-MUFFIN PAN42.404
CELEBRATE TRANSPARENT PIPING BAG 45CM U33.585
WILTON 12-CUPCAKE PAN27.836
TIP # 6B OPEN STAR24.007
DECORATIVE BRUSHES 92297523.148
TRANSPARENT PIPING BAG 30CM (unit)21.609

1. Ranking profit in descending order, what position does the product ROUNDED SMOOTHER occupy?

2. Ranking profit in ascending order, what position does the product WILTON 12-CUPCAKE PAN occupy?

Solution

1. =RANK(B3; B1:B11; FALSE) = 5

2. =RANK(B9; B1:B11; TRUE) = 10

INDEX function or ÍNDICE

The INDEX function returns the contents of a cell specified by row and column offset.

INDEX function syntax

=INDEX(table_array; row_num; [column_num])

Where:

- table_array is the range where the search will be performed;

- row_num is the number of the row being searched;

- column_num is the number of the column being searched;

Details to note:

- It is possible not to pass the column being searched as an argument; if you do not pass it, the entire row being searched will be returned

- It's like playing Battleship

Example

productprofitRank
TRANSPARENT PIPING BAG 30CM C/100UN100.001
CELEBRATE CAKE STAND 5UN93.692
PROFESSIONAL SILICONE MAT52.723
WILTON 6-MUFFIN PAN42.404
CELEBRATE TRANSPARENT PIPING BAG 45CM U33.585
WILTON 12-CUPCAKE PAN27.836
TIP # 6B OPEN STAR24.007
DECORATIVE BRUSHES 92297523.148
TRANSPARENT PIPING BAG 30CM (unit)21.609

1. What data is in column 2, row 3?

2. What data is in column 3, row 1?

3. What data is in column 3, row 4?

Solution

1. =INDEX(A1:C15; 3 ; 2) = 2

2. =INDEX(A1:C15; 1 ; 3) = "Lesson"

3. =INDEX(A1:C15; 4 ; 3) = "Frequency distribution: collecting data in the field"

MATCH function or CORRESP

The MATCH function returns the relative position of an item in the range that matches the specified value.

MATCH function syntax

=MATCH(search_key; range; [search_type])

Where:

- search_key is the value to be searched for. For example, "42", "Cats" or "I24";

- range is the one-dimensional array to be searched.;

- search_type: "1" (default) finds the largest value less than or equal to the "search_key" when the "range" is sorted in ascending order. "0" finds the exact value when the "range" is not sorted. "-1" finds the smallest value greater than or equal to the "search_key" when the "range" is sorted in descending order.

Example

productprofitRank
TRANSPARENT PIPING BAG 30CM C/100UN100.001
CELEBRATE CAKE STAND 5UN93.692
PROFESSIONAL SILICONE MAT52.723
WILTON 6-MUFFIN PAN42.404
CELEBRATE TRANSPARENT PIPING BAG 45CM U33.585
WILTON 12-CUPCAKE PAN27.836
TIP # 6B OPEN STAR24.007
DECORATIVE BRUSHES 92297523.148
TRANSPARENT PIPING BAG 30CM (unit)21.609

1. In which row is the product named "PROFESSIONAL SILICONE MAT"?

Solution

1. =MATCH("PROFESSIONAL SILICONE MAT"; A1:A11;1) = 10

INDEX + MATCH functions or ÍNDICE + CORRESP

The INDEX + MATCH combination provides the versatility that the VLOOKUP or HLOOKUP functions lacked.

INDEX + MATCH combination syntax

=INDEX(table_array;MATCH(search_key; range; [search_type]); column_num)

Example

productprofitRank
TRANSPARENT PIPING BAG 30CM C/100UN100.001
CELEBRATE CAKE STAND 5UN93.692
PROFESSIONAL SILICONE MAT52.723
WILTON 6-MUFFIN PAN42.404
CELEBRATE TRANSPARENT PIPING BAG 45CM U33.585
WILTON 12-CUPCAKE PAN27.836
TIP # 6B OPEN STAR24.007
DECORATIVE BRUSHES 92297523.148
TRANSPARENT PIPING BAG 30CM (unit)21.609

1. What is the name of the product with profit R$ 27.83?

2. What is the profit of the product named PROFESSIONAL SILICONE MAT?

Solution

1. =INDEX(A1:C11;MATCH("27.83"; B1:B11;1); 1)

2. =INDEX(A1:C11;MATCH("PROFESSIONAL SILICONE MAT"; A1:A11;1); 2)

Exercises

Click here to access the spreadsheet to solve the next exerciseslink outside website.

1. What is the name of the product with code 102?

2. What is the name of the product with the third highest profit?

3. What is the name of the product that sold the second most in time 1?

Student Table:
RegistrationNameCourseGrade 1Grade 2Average
1001João SilvaMathematics8.57.07.75
1002Maria OliveiraHistory9.08.58.75
1003Pedro SantosPhysics6.57.57.0
1004Ana CostaChemistry7.08.07.5
1005Carlos MendesBiology5.56.05.75
1006Luiza FernandesMathematics10.09.59.75
1007Rafaela AlmeidaHistory8.08.08.0
1008Bruno PereiraPhysics7.57.07.25
1009Fernanda LimaChemistry6.07.56.75
1010Gabriel SouzaBiology9.08.58.75
Questions:

4. What is the average of the student with registration 1004?

5. What is the course of the student Luiza Fernandes?

6. What is the highest grade 1 among students in the Mathematics course?

7. How many students have an average greater than 8.0?

Inventory Table:
ProductJanuaryFebruaryMarchApril
Rice500450480490
Beans300280290310
Sugar200220210230
Coffee150160155165
Oil100110105115
Questions:

8. What was the stock of Sugar in the month of March?

9. What was the product with the lowest stock in the month of February?

10. What was the variation in Coffee stock between January and April?

11. What was the average stock of Beans over the four months?

Employee Table:
IDNamePositionSalaryDepartment
001Ana PaulaAnalyst4500.00IT
002Carlos EduardoManager8000.00Sales
003Mariana SilvaDeveloper5500.00IT
004João PedroAnalyst4200.00HR
005Luiza CostaManager8500.00Marketing
006Pedro HenriqueDeveloper6000.00IT
007Fernanda LimaAnalyst4300.00Sales
008Rafael SouzaManager8200.00HR
009Bruna OliveiraDeveloper5800.00IT
010Lucas MendesAnalyst4100.00Marketing
Questions:

12. What is the salary of the employee with ID 003?

13. What is the position of the employee Luiza Costa?

14. What is the department with the highest average salary?

15. How many employees have a salary above 5000.00?