Informazioni sull’esercizio
Un set di dati di 430 righe su 2 fogli, una cella di risposta, circa 10 minuti. Correzione nel tuo browser: il valore e la formula che lo produce, con indicazioni su cosa sistemare.
Come risolverlo
- Customers!C2
=MAXIFS(Orders!$B$2:$B$401,Orders!$C$2:$C$401,A2)
Excel stores a date as a serial number — the count of days since 1 January 1900 — so "the most recent date" is simply the largest number. MAXIFS(dates, customers, A2) takes the maximum of the dates on rows whose customer equals the name in A2, which is the last order whatever the sort order of the sheet. XLOOKUP with search mode −1 reaches the same cell differently: it scans the customer column from the bottom and returns the date of the first match it meets, which is the latest order only because the Orders sheet is sorted oldest-first.
Pitfall 1: XLOOKUP(…,-1) depends on the sort order; a sheet sorted by order ID or by customer breaks it silently, MAXIFS does not care. Pitfall 2: MAXIFS returns 0 for a customer with no orders, which a date format shows as 1900-01-00; XLOOKUP returns #N/A. Wrap either in IF or IFNA when the list can contain prospects. Pitfall 3: the result is a serial number until the cell carries a date format — the grader compares numbers, so an unformatted correct answer still passes, but the report reader will not understand 46,250. Pre-2019 alternatives: =MAX(IF(Orders!$C$2:$C$401=A2,Orders!$B$2:$B$401)) entered with Ctrl+Shift+Enter, =LOOKUP(2,1/(Orders!$C$2:$C$401=A2),Orders!$B$2:$B$401) (the classic "last match" trick, sort-order dependent) and =AGGREGATE(14,6,Orders!$B$2:$B$401/(Orders!$C$2:$C$401=A2),1). Performance: MAXIFS scans 400 rows for each of 30 customers — trivial; on a million-row log a pivot table with Max of Order date is the better tool.
Altri metodi validi
- =XLOOKUP(A2,Orders!$C$2:$C$401,Orders!$B$2:$B$401,,0,-1) — Excel 365; search mode −1 = last to first, relies on the date sort
- =MAX(IF(Orders!$C$2:$C$401=A2,Orders!$B$2:$B$401)) — array formula (Ctrl+Shift+Enter before Excel 365)
- =LOOKUP(2,1/(Orders!$C$2:$C$401=A2),Orders!$B$2:$B$401) — the classic last-match trick; also sort-order dependent
- =AGGREGATE(14,6,Orders!$B$2:$B$401/(Orders!$C$2:$C$401=A2),1) — LARGE(…,1) ignoring the errors produced by non-matching rows
Errori comuni
A plain lookup: =XLOOKUP(A2,Orders!$C$2:$C$401,Orders!$B$2:$B$401) or a VLOOKUP returns the first matching row, which on a sheet sorted oldest-first is the customer's earliest order of the year, not the last.
Come valutiamo
È accettata qualsiasi formula che produce il risultato giusto, a meno che l’attività non indichi una funzione: in quel caso un’altra funzione vale metà dei punti. Confrontiamo i valori con una piccola tolleranza e ignoriamo maiuscole, minuscole e spazi nel testo. Un numero corretto digitato a mano invece di una formula vale metà dei punti. Le attività su più celle valgono il punteggio pieno con il 100% delle celle giuste, metà dei punti dal 50%. Dove serve, cambiamo anche una cella di input su una copia del tuo foglio e controlliamo che la formula si aggiorni.
Risposte calcolate con le regole di Excel 365 e verificate nel nostro correttore in data 16 novembre 2026. Autore: GridBelt team.