How to Fix Excel IF Formulas with Multiple Conditions Using XMATCH
Question details
The user needs a reliable formula to check whether a specific service code falls into various predefined data ranges, applying different conditional calculations and minimum constraints based on the match.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Creating a nested conditional formula that tests a target cell against multiple service-code ranges using XMATCH to determine which specific arithmetic operations to execute.
- Observed behavior
- The formula needs to correctly evaluate multiple ranges and apply minimum constraints without logical conflicts, particularly when those lookup ranges overlap.
Verify that your spreadsheet contains the correct reference ranges for your service codes. If any of your data ranges overlap, determine which condition should take priority, as nested IF statements process conditions in a strict sequential order.
Use a Nested IF Formula Combined with ISNUMBER and XMATCH
Combine the IF, ISNUMBER, and XMATCH functions to dynamically check if a specific code exists in your predefined ranges and automatically apply the corresponding calculation.
XMATCH is an advanced lookup function that returns the relative position of an item in an array. By wrapping it in the ISNUMBER function, you turn the positional result into a TRUE/FALSE value, making it perfectly suited for an IF statement's logical test.
When dealing with multiple conditions, Excel evaluates nested IF statements sequentially from left to right. It will stop and return a result on the very first TRUE condition it encounters.
Click on the cell where you want the calculated result to be displayed.
Enter the following formula: =IF(ISNUMBER(XMATCH(C18,E91:E95)),K18+K32+K34-K36,IF(ISNUMBER(XMATCH(C18,E138:E143)),MAX(SUM(K32:K35)-K36,8500),IF(ISNUMBER(XMATCH(C18,E86:E135)),MAX(SUM(K32:K35)-K36,7000),"")))
Modify the cell references (like C18 for your service code and the E91:E95 ranges for your lookup lists) to match the actual layout of your workbook data.
Press Enter to execute the formula. If you are calculating a column of service codes, drag the fill handle down to apply the logic to other rows.

Handle Complex Formulas Easily with WPS Spreadsheet
WPS Spreadsheet is a powerful data analysis tool that natively supports advanced functions like XMATCH, nested IFs, and dynamic array formulas. You can seamlessly execute complex multi-condition calculations while maintaining full compatibility with your existing workbooks.
- 1. Open your workbook: Launch WPS Spreadsheet and open your existing Excel workbook (.xlsx).
- 2. Insert the function: Select your target cell and click the 'Insert Function' (fx) icon located next to the formula bar to start building your logic.
- 3. Evaluate the results: Paste your combined ISNUMBER and XMATCH formula into the bar and press Enter to instantly calculate your conditions.

Frequently Asked Questions
Why does my nested IF formula ignore my second condition?
Nested IF formulas evaluate sequentially from left to right. Once Excel finds the first condition that evaluates to TRUE, it processes that calculation and skips the rest of the formula. If your lookup ranges overlap, ensure your most specific, highest-priority condition is placed first.
What is the difference between MATCH and XMATCH in Excel?
XMATCH is the modern successor to the MATCH function. It defaults to an exact match, can search from the bottom up, and is generally faster than traditional MATCH. Both can be wrapped with ISNUMBER to create a TRUE/FALSE logic test for IF statements.
How can I prevent negative values in my IF formula calculations?
You can wrap your arithmetic operation inside the MAX function. For example, using MAX(SUM(K32:K35)-K36, 0) ensures that if the final result is less than zero, the formula will output 0 instead. In our solution, MAX(..., 8500) enforces a strict minimum baseline of 8500.
Will XMATCH work if I am using an older version of Excel?
XMATCH is only available in Microsoft 365, Excel 2021, and modern spreadsheet software like WPS Office. If you open the file in an older version of Excel (like 2016 or 2019), XMATCH will return a #NAME? error. To ensure backwards compatibility, substitute XMATCH with the standard MATCH(lookup_value, lookup_array, 0) function.




