Excel Formula for Premiums: Using IF, AND, or INDEX MATCH
Question details
The user needs to create an Excel formula that calculates the correct premium amount based on two simultaneous conditions: the selected plan and the pet type.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Determining an insurance or service premium rate where the final price depends on a combination of user selections across multiple variables.
- Observed behavior
- Users frequently attempt to write excessively long, nested IF and AND statements, resulting in formulas that are difficult to manage, error-prone, and hard to update.
Ensure your lookup data (plans, pet types, and corresponding premium rates) is organized in a clear, structured table. It is highly recommended to place your reference grid in a separate range or sheet to keep your primary calculator clean.
Build a Two-Way Lookup Using INDEX and MATCH
Instead of writing a complex nested IF formula, using an INDEX and MATCH combination performs a two-way lookup that is far more efficient for finding a value based on row and column intersections.
When dealing with multiple variables (such as checking both 'Plan Type' and 'Pet Type' simultaneously), an INDEX and MATCH formula searches horizontally and vertically to pinpoint the exact value in a grid.
This method separates data from logic. If your premium rates change in the future, you only need to update the values in your table without modifying the formula.
Set up a table where cells A6:A9 contain the plan names, cells B5:C5 contain the pet types (e.g., Dog, Cat), and cells B6:C9 contain the actual premium values.
Dedicate cells for data entry. For example, use cell A2 for typing or selecting the chosen plan and cell B2 for the chosen pet type.
Select your result cell, type =INDEX($B$6:$C$9,MATCH(A2,$A$6:$A$9,0),MATCH(B2,$B$5:$C$5,0)), and press Enter. This extracts the exact premium located at the intersection of the matching plan row and pet type column.

Construct a Nested IF and AND Formula (Alternative)
If you only have a very small number of variables, you can use the IF function combined with AND to evaluate the criteria directly, though it is less scalable.
Effortlessly Handle Complex Formulas in WPS Spreadsheet
WPS Spreadsheet offers full support for advanced lookup functions like INDEX and MATCH, allowing you to build dynamic premium calculators with ease. It perfectly mimics the formula logic of Microsoft Excel, ensuring your files work flawlessly.
- 1. Open your workbook in WPS: Launch WPS Office and open your .xlsx or .xls file containing your premium lookup data.
- 2. Insert your lookup functions: Navigate to the Formulas tab to use 'Insert Function' if you need guidance with syntax, or directly type =INDEX(...MATCH...) into the formula bar.
- 3. Calculate your premiums automatically: Enter your references and press Enter to instantly calculate your multi-criteria results with total precision.

Frequently Asked Questions
Why does my INDEX and MATCH formula return an #N/A error?
An #N/A error means the software cannot find an exact match for your lookup value. Ensure the text in your input cells (like Plan or Pet Type) matches the headers and rows in your lookup table exactly, with no hidden trailing spaces or spelling errors.
Can I use XLOOKUP instead of INDEX and MATCH for two-way lookups?
Yes. If you are using a newer version of Excel or WPS Office, you can nest two XLOOKUP functions to achieve the same result. The syntax involves placing one XLOOKUP inside the return_array of another, like so: =XLOOKUP(A2,$A$6:$A$9,XLOOKUP(B2,$B$5:$C$5,$B$6:$C$9)).
What is the limit for nesting IF functions in Excel?
In modern versions of Excel and WPS Spreadsheet, you can nest up to 64 IF functions in a single cell formula. However, nesting that many functions makes the formula extremely hard to read and debug, which is why table-based lookups (like INDEX/MATCH) are strongly recommended.
Can I use the IFS function instead of nested IF and AND?
Yes, the IFS function lets you test multiple conditions in order without writing 'IF' repeatedly. The syntax looks like this: =IFS(AND(A2="Basic",B2="Dog"), 30, AND(A2="Basic",B2="Cat"), 25...). It evaluates conditions from left to right and stops at the first true statement.




