Über diese Übung
Ein Datensatz mit 200 Zeilen auf einem Tabellenblatt, eine Antwortzelle, etwa 8 Minuten. Bewertet in Ihrem Browser: der Wert und die Formel dahinter, mit Feedback, das die Korrektur benennt.
So lösen Sie die Aufgabe
- F2
=SWITCH(B2,"N","North","S","South","E","East","W","West","C","Central","Unknown")
SWITCH takes one expression — the code in B2 — and a list of value/result pairs: when the code equals "N" it returns "North", when it equals "S" it returns "South", and so on. An odd final argument is the default, returned when nothing matched, which is how the blank and mistyped codes become Unknown instead of an error. IFS does the same with explicit tests (B2="N", B2="S", …) and a TRUE,"Unknown" pair at the end; both read far better than four nested IFs.
Pitfall 1: forgetting the default — SWITCH without it returns #N/A for the unmapped codes, and IFS without the TRUE branch does the same, which then poisons every COUNTIF and pivot built on the column. Pitfall 2: SWITCH only tests equality against one expression; for ranges (>=) you need IFS or a lookup. Comparisons are case-insensitive ("n" matches "N") but a trailing space in the code is a different value — TRIM(B2) when the export is dirty. Pitfall 3: a mapping typed into a formula is hidden from the people who maintain the codes; once the list has more than a handful of entries, put it in a two-column table and use XLOOKUP(B2,codes,names,"Unknown") or VLOOKUP with IFERROR. Version notes: SWITCH and IFS exist in Excel 2019, 365 and the web app; in Excel 2016 and earlier use nested IF or CHOOSE(MATCH(B2,{"N","S","E","W","C"},0),…) wrapped in IFERROR. Performance: all variants are trivial at 200 rows; the lookup version is also the fastest to recalculate once the sheet grows to hundreds of thousands of rows.
Andere Wege, die funktionieren
- =IFS(B2="N","North",B2="S","South",B2="E","East",B2="W","West",B2="C","Central",TRUE,"Unknown") — IFS with a catch-all TRUE branch
- =IFERROR(XLOOKUP(B2,{"N","S","E","W","C"},{"North","South","East","West","Central"}),"Unknown") — Excel 365; a lookup against inline arrays (not accepted by this task, which asks for SWITCH or IFS)
- =IF(B2="N","North",IF(B2="S","South",IF(B2="E","East",IF(B2="W","West",IF(B2="C","Central","Unknown"))))) — the nested-IF version this exercise replaces
Häufige Fehler
Leaving out the default value: =SWITCH(B2,"N","North",…,"C","Central") returns #N/A on the 6 rows with an unknown code, and the first of those is the cell the grader names.
So bewerten wir
Jede Formel, die das richtige Ergebnis liefert, wird akzeptiert, außer die Aufgabe nennt eine Funktion: Dann bringt eine andere Funktion die halbe Punktzahl. Wir vergleichen Werte mit einer kleinen Toleranz und ignorieren bei Text Groß- und Kleinschreibung sowie Leerzeichen. Eine richtige Zahl, die statt einer Formel von Hand eingetippt wurde, bringt die halbe Punktzahl. Aufgaben mit mehreren Zellen bringen die volle Punktzahl, wenn 100% der Zellen stimmen, und die halbe ab 50%. Wo es darauf ankommt, ändern wir außerdem eine Eingabezelle in einer Kopie Ihrer Tabelle und prüfen, ob Ihre Formel mitzieht.
Antworten nach den Regeln von Excel 365 berechnet und am 16. November 2026 in unserem Bewertungssystem geprüft. Verfasst von GridBelt team.