SWITCH in WPS Spreadsheet: Map Exact Values with a Clear Default
Map WPS values to results using SWITCH, inspect duplicate-match priority and distinguish a final default from an ordinary value/result pair.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Quick answer: SWITCH compares one expression with listed values and returns the result paired with the first match. An optional final default handles expressions that match none of the listed values. A final value/result pair is not the same thing as a default.
Availability and version history
- Introduced: documented by 2019-06-18 in the official WPS lesson; original introduction is not established.
- Availability: WPS Office for Windows Personal; no numeric release is stated in the edition metadata.
- Scope: exact current supported builds remain unverified. The Windows lesson does not establish equivalent availability in other WPS clients.
- Checked: October 14, 2026 against function-specific documentation. Examples were independently calculated; no native WPS test was performed.
Syntax and argument pairing
=SWITCH(expression, value1, result1, [value2, result2], ..., [default])
The expression and at least one value/result pair are required. Every listed value needs its corresponding result. A default, when supplied, is the last unpaired argument. Square brackets indicate optional parts and are not typed.
The dated Windows Personal lesson describes up to 126 value/result pairs within 254 total arguments. That is historical documentation, not a verified maximum for all current WPS builds. Examples use English function names and comma separators.
Example 1: map numeric codes into readable labels
Put codes 1, 2, 3 and 9 in A2:A5. Enter in B2 and fill down:
=SWITCH(A2,1,"Queued",2,"Working",3,"Done","Check code")
Expected labels are Queued, Working, Done and Check code. The last string is the default because it is not preceded by a new comparison value. Code 9 reaches that fallback.
The function returns a chosen label; it does not change the source code or verify that the recorded business state is accurate. Keep the original column visible when auditing a mapping.
Example 2: distinguish a fallback from one more mapping
=SWITCH(9,1,"Queued",2,"Working",8,"Special","Check code")
Expected result: Check code. Replacing expression 9 with 8 returns Special. The value 8 and result Special are an ordinary mapping, followed by a genuine default.
The Academy walkthrough ends its weekday example with an 8/value pair. That handles code 8; it is not a catch-all default for every unknown code. This guide does not assign a native no-match error to a formula that omits its default, because the captured lesson does not specify that exact result.
Advanced example: duplicate values use the first match
=SWITCH(2,2,"First",2,"Second","Unknown")
Expected result: First, following the documented first-match rule. Reversing the two result labels makes Second the selected label. A duplicate mapping is not automatically flagged as invalid.
Keep mapping keys unique unless the priority is deliberate. Adding a later correction with the same value will not override an earlier pair that already matches.
Advanced example: map an expression rather than a stored code
On a separate sheet enter these numeric pairs:
| A · Actual | B · Target |
|---|---|
| 9 | 10 |
| 10 | 10 |
| 11 | 10 |
| 13 | 10 |
In C2 use and fill:
=SWITCH(A2-B2,-1,"One below",0,"On target",1,"One above","Larger difference")
Expected labels are One below, On target, One above and Larger difference. The expression is calculated first; its value is then compared with the listed -1, 0 and 1.
These are exact integer controls. A measurement intended to be zero but stored as a tiny nonzero decimal is a different value. Decide any rounding policy explicitly before using exact-code mappings on measured quantities.
Advanced example: return numeric results for later calculation
For codes 1, 2, 3 and 2 in E2:E5:
=SWITCH(E2,1,4,2,10,3,18,0)
Expected numeric results are 4, 10, 18 and 10, totalling 42. The last zero is an intentional numeric fallback. Quoting the results would instead create text values with different behavior in later reference-based calculations.
A default zero is appropriate only if unknown codes really should contribute zero under the policy. Otherwise use a visible warning and handle it separately; a convenient total is not proof that every code was recognized.
Choosing between SWITCH, IFS and a lookup table
SWITCH expresses an equality mapping against a single calculated value. IFS directly lists different Boolean conditions, such as descending score thresholds. IF is often enough for a single two-outcome choice.
A long mapping that changes regularly can be easier to maintain as a separate data table rather than many hard-coded pairs. Whichever approach is used, test one example for every intended mapping and at least one unmatched value.
Remaining matching and evaluation limits
The source establishes first matching value and optional default, not a complete case-sensitivity, text/number equivalence, wildcard or native error table. It also does not establish that all unselected result expressions are skipped during evaluation.
The examples therefore use explicit numeric codes and straightforward results. Do not interpret the match-selection rule as a guarantee that a problematic later argument can never cause an error.
References and verification
- WPS Academy: SWITCH lesson, 2019-06-18 (Chinese; Windows Personal scope).
- Editorial testing standards.
Worked outputs are independently calculated expectations, not captured native results. The dated source establishes the stated product scope, not every current client or build.