The book: files and exercises · Lesson 18 of 24

Lesson 18 exercises: UNIQUE, SORT, FILTER and SEQUENCE

Five exercises on dynamic arrays, with the gym class students from lesson18.xlsx: a sorted list with no duplicates, counts with F4#, a filter by day and a sort by monthly fee. Here the result spills into the cells next to it, as in Microsoft 365.

Lesson 18. Formulas that spill: UNIQUE, SORT, FILTER and SEQUENCE

Use the Exercises sheet of lesson18.xlsx: the students of a gym's classes, with class, day and monthly fee.

Files: lesson18.xlsx · solutions: lesson18-solutions.xlsx.

In the exercises with a sheet, type the formula in the fx bar and click Check: the sheet works it out the way Excel does, with commas between the arguments (semicolons work too), and also tries it with other data, to see whether it still works when the data changes. In the other exercises, you work in Excel with the lesson's file and type the result here.

At the end of the page you'll find the lesson's Bonus challenge: one more exercise, whose answer isn't in the book. You check it only here.

Exercise 1

In F4, write a single formula that gives the list of classes, with no duplicates and in alphabetical order. How many classes are there?
In cell F4
fx
How many classes are there?
Show the answer

=SORT(UNIQUE(B4:B13)) = Pilates, Spinning, Yoga, Zumba (in F4:F7): 4 classes.

Exercise 2

In G4, count the students in each class with COUNTIF (Lesson 9), using the result in F4 as the criteria argument. Which class has the most students, and how many?
In cell G4
fx
Which class has the most students?
How many students does it have?
Show the answer

=COUNTIF(B4:B13,F4#) = 2, 2, 4, 2 (in G4:G7): Yoga, with 4 students.

Exercise 3

J2 holds a day of the week. In I4, write a formula that shows all the students of that day (all four columns) and, if there are none, the text Nobody. Who comes on Thursday? What does the formula show if you type Saturday in J2?
In cell I4
fx
Who comes on Thursday? (separate the first names with commas)
What does the formula show if you type Saturday in J2?
Show the answer

=FILTER(A4:D13,C4:C13=J2,"Nobody"): on Thursday Ryan (Yoga), Linda (Yoga) and Carlos (Spinning) come. With Saturday, the formula shows Nobody.

Exercise 4

Put Thursday back in J2 and change the formula in I4 so the students are sorted by monthly fee, from highest to lowest. Who comes first, and how much does that student pay?
In cell I4
fx
Who comes first?
How much does that student pay?
Show the answer

=SORT(FILTER(A4:D13,C4:C13=J2,"Nobody"),4,-1): Carlos comes first and pays $50.00 (Spinning).

Exercise 5

Without Excel: in N4 of an empty sheet you type =SEQUENCE(3). a) What appears, and in which cells? b) What does N4 show if N5 already held some text?
a) In which cells do the numbers 1, 2 and 3 appear?
b) What does N4 show if N5 already held some text?
Show the answer

a) The numbers 1, 2 and 3, in N4, N5 and N6. b) #SPILL!: N5 is in use, so the result can't spill.

Bonus challenge

The answer isn't in the book: you check it only here.

Exercises sheet: in H4, write a single formula that gives, in alphabetical order, the first names of all the students whose monthly fee is more than $40. Who comes first?
In cell H4
fx
Who comes first?
Show the answer

=SORT(FILTER(A4:A13,D4:D13>40)). FILTER takes only the first names (A4:A13) with the condition D4:D13>40, and SORT, on the outside, puts them in alphabetical order. Four students pay more than $40: Jake and Tyler ($45.00 each), Sarah and Carlos ($50.00 each). In alphabetical order, H4:H7 shows Carlos, Jake, Sarah and Tyler, so Carlos comes first. With >=40 instead of >40, the Yoga students would come in too, because they pay exactly $40.00.