← Level 5 – Modeller

4 / 12 ⏱ 22 minutes Premium

A price list: looking things up in a list

How much would snacks for the whole class cost? XLOOKUP finds the price in a price list.

A price list

Imagine your class wants to buy snacks based on the survey. How much would it cost? You need a price list and XLOOKUP.

Make a price list

  1. Add a new sheet called Prices.

  2. Type Snack in A1 and Price in B1.

  3. Fill it in: sandwich 3, apple 1, cookie 2, banana 1, nothing 0.

A list like this is called a lookup table. The prices are in one place. When a price changes, you only change it here.

Find the price for each answer

  1. On the Answers sheet, type Price in D1.

  2. In D2, type =XLOOKUP(C2,Prices!A:A,Prices!B:B,"?").

  3. Drag D2 down to D21. Every answer has a price.

  4. Under the table, in C23, type Total, and in D23, =SUM(D2:D21). You’ll see $37.

Prices!A:A means the whole column A on the Prices sheet. When you add another snack to the price list, the formula finds it too.

💡

Try raising the price of a sandwich to $4. The total changes by itself.

The question mark

If the answers had a snack that isn’t on the price list, XLOOKUP would write ?. That’s the fourth part of the formula. You can see right away what’s missing from the price list.

⚠️

The words have to be written exactly the same. sandwich and sandwich (with a space) are two different things to XLOOKUP. That’s why we look in column C, which we cleaned up in Sorter.

Your turn 💪

  1. You have a Prices sheet.
  2. Every answer has a price.
  3. You know how much snacks for the whole class would cost.
✅

Done when: the spreadsheet finds the price for every answer.

What to take away from this lesson