Looking things up
On the Dashboard, the Favorite snack cell is still empty. Now you’ll learn a formula that finds the winner by itself.
The XLOOKUP function finds something in one column and returns the matching value from another column.
=XLOOKUP(what I'm looking for, where I'm looking, what to return)
Find the winner
First, you find out how many votes the winner has. That’s the biggest number: =MAX(Survey!B2:B6) → 8.
Then you find which snack that 8 belongs to:
-
On the
Dashboardsheet, click on B5. -
Type
=XLOOKUP(MAX(Survey!B2:B6),Survey!B2:B6,Survey!A2:A6). -
You’ll see sandwich.
You read it like this: “Find the biggest number of votes in column B, and give me the snack from the same row in column A.”
Try changing the answers on the Answers sheet so that banana has more votes. The winner on the Dashboard changes by itself.
Older Excel
The XLOOKUP function is in Google Sheets and in Excel 365. Older Excel has VLOOKUP:
=VLOOKUP(what I'm looking for, table, which column to return, FALSE)
But VLOOKUP can only look in the first column of the table and return values to the right of it. It wouldn’t work for our winner, because the votes are to the right of the snacks. That’s why XLOOKUP is better.
When two snacks have the same number of votes, XLOOKUP returns the first one. Watch out for a tie.
When it finds nothing
When XLOOKUP finds nothing, it shows the error #N/A. But you can tell it what to write instead of the error. You add a fourth part:
=XLOOKUP("pizza",Survey!A2:A6,Survey!B2:B6,"not on the list")
Đến lượt bạn 💪
- B5 on the
Dashboardshows the survey winner. - When the votes change, the winner changes.
- You know what the three parts of XLOOKUP mean.
Done when: the spreadsheet finds the survey winner by itself.
What to take away from this lesson
- XLOOKUP: what I’m looking for, where I’m looking, what to return.
- Winner = XLOOKUP with MAX.
- Older Excel: VLOOKUP, which only looks to the right.
- The fourth part says what to write when nothing is found.
© 2026 Ing. Martin Polak / AlgoRhino · Điều khoản sử dụng nội dung