How to Evaluate Number Intervals in Excel: Fix SWITCH Function Limitations
Question details
The user needs to classify numerical values into specific categories (e.g., A, B, or C) based on numerical intervals, but the SWITCH function is unable to evaluate paired logical conditions or greater than/less than rules.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Categorizing numerical data into distinct ranges or intervals for grading, scoring, or data classification.
- Observed behavior
- The SWITCH function fails or returns an error because it expects exact value matches rather than boolean logic ranges, leaving the user unable to classify numbers properly.
Ensure that the target cell containing the value to be evaluated is formatted as a number, and clearly define the upper and lower limits of each interval to prevent unhandled data gaps or overlapping ranges.
Use Nested IF and AND Functions
Since SWITCH only handles exact matches, combining nested IF statements with the AND function allows you to evaluate complex, paired logical conditions for number intervals.
The IF function can evaluate whether a condition is TRUE or FALSE, while the AND function allows you to test multiple conditions simultaneously (such as a number being greater than X but less than or equal to Y). Nesting these functions allows you to test sequential intervals.
It is crucial to include a final 'value_if_false' statement to handle any numbers that fall completely out of your defined ranges, such as negative numbers or values exceeding your maximum expected limit.
Click on the cell where you want the categorized result (e.g., A, B, or C) to appear.
Type the formula combining IF and AND. For example, to evaluate cell AA6: =IF(AND(AA6>0,AA6<=3),"A",IF(AND(AA6>3,AA6<=6),"B",IF(AND(AA6>6,AA6<=12),"C","Out of Range")))
Press Enter to execute the formula. Then, click and hold the fill handle (the small square at the bottom right of the selected cell) and drag it down to apply the formula to the rest of your data column.

Easily Manage Complex Formulas with WPS Office
WPS Spreadsheet fully supports advanced logical formulas including nested IF, AND, and SWITCH. You can seamlessly classify data into intervals just like in Excel, completely for free.
- 1. Open your spreadsheet: Launch WPS Office and open your workbook using WPS Spreadsheet.
- 2. Select your output cell: Click the empty cell beside your numerical data where you want the category text to display.
- 3. Input the logic formula: Paste your nested IF and AND formula directly into the formula bar at the top of the interface.
- 4. Apply to multiple cells: Press Enter, then double-click the green fill handle in the cell's corner to automatically populate the rest of the column.

Frequently Asked Questions
Why doesn't the SWITCH function work with greater than or less than operators?
The SWITCH function is inherently designed to evaluate exact value matches against a single expression. It evaluates whether an expression exactly equals a specified value. It cannot process paired logical conditions or inequality operators like greater than (>) or less than (<), making it unsuitable for dynamic number intervals.
Can I use the IFS function instead of nested IFs for number intervals?
Yes, if you are using a modern version of spreadsheet software. The IFS function evaluates multiple conditions sequentially without the need for complex nesting. You can use it like this: =IFS(AND(AA6>0,AA6<=3),"A", AND(AA6>3,AA6<=6),"B", AND(AA6>6,AA6<=12),"C", TRUE, "Out of Range").
What happens if a value falls exactly on the boundary of an interval?
The resulting behavior strictly depends on the specific operators you use in your formula. Using the less than or equal to operator (<=) includes that boundary number in the interval, whereas using strictly less than (<) excludes it. It is highly recommended to check your logic to ensure boundary conditions never overlap.




