Replace 25+ Nested IFs with a Single Simple Lookup

I was recently asked the following question: “I have a drop-down with 25+ categories that determines the fee percentage. Can I use an IF function to compute the fee based on the selected category?” I answer this question in this post.



Let’s begin by understanding the objective and the question.

There is an in-cell drop down that enables the user to pick a Category (from a list of 25+ categories) in C9. The price for the product is entered into C10. And we want Excel to compute the Fee in C11.

The initial question asks how to use an IF function to compute the Fee based on the Category and Price. So, with that context provided, let’s jump in.


We’ll walk through this process using a couple of exercises.

Exercise 1: Conditional logic with IF, IFS, and SWITCH

Let’s start with the suggested approach of using the IF function. We would start with the first category, category “A” like this:

=IF(C9="A",C10 * 0.01)

As you can see, if the Category is A then the fee is the Price C10 times 0.01 or 1%. If the category is B, then the fee is 2%, so we could address this by nesting in an additional IF function to our formula:


Category C is computed at 3%, so we’d nest an additional IF function like this:


And we could continue nesting IF functions to address all 25+ categories like this:


However, even the biggest IF fans will agree that dealing with multiple nested IF statements can become cumbersome. Not only are they challenging to write, but they’re also tough to maintain and update over time. Like, I can’t even imaging trying to update the fee percentages for each category!

There are other functions that have come out recently that can help simplify this slightly, such as IFS and SWITCH. But they are still cumbersome. For example, we could replace the above function that uses nested IF function with the following:


As you can see, it is slightly less complex.

Or, we could use SWITCH, which also helps a bit:


But, there is a better option in this scenario, so let’s get to it before my brain implodes.

Exercise 2: lookup table

Rather than embedding the fee rates directly into the formula, as we did above, we can store them in cells, like this:

Then, based on the category chosen, we can retrieve the correct fee percentage from this lookup table. So, how can we do that? Well, that leads us to the next exercise.

Exercise 3: single lookup

With the fee schedule created, we can retrieve the correct rate using our favorite lookup function, whether that is VLOOKUP, XLOOKUP, INDEX/MATCH or other.

For example, we’d like to write a formula in C6 that multiplies the Price by the corresponding fee:

We can write the following formula into C6:


This multiplies the percentage returned by XLOOKUP by the price in C5:

And we got it!

In the end, we replace an intricate approach using over 25 different conditions with a single simple lookup function. And the best part is that is was easy to write AND maintain going forward. When there are rate changes, all we need to do is update the lookup table. No changes are needed to our formula 🙂

Note: For more about the XLOOKUP function, check out this post.


That is how we can replace 25+ nested IFs with a simple single lookup function. Mission accomplished!

If you have any enhancements, questions, or suggestion … please share by posting a comment below, thanks!

Sample File


Q: Can I use a dropdown of 25+ categories to compute the fee with an IF function?

Yes, but it results in an unnecessarily complex setup. Using a fee schedule with a lookup function simplifies this process.

Q: Is the IFS function more efficient than nested IF statements?

Yes, it is more efficient as it reduces the need for repetitive IF functions. The SWITCH function also provides a cleaner approach than nested IFs. However, in this type of scenario, a lookup table would be the way to go.

Q: What is amore efficient method for calculating fees based on category?

The XLOOKUP function in conjunction with a lookup table is a more streamlined approach. It eliminates excessive conditional statements and simplifies formula construction by removing the fees from the formula and places them into cells which are easy to read and update.

Q: How can I convert the percentage found by XLOOKUP into a fee?

You simply need to multiply the percentage found by XLOOKUP by the price.

Posted in ,

Jeff Lenning

I love sharing the things I've learned about Excel, and I built Excel University to help me do that. My motto is: Learn Excel. Work Faster.

Excel is not what it used to be.

You need the Excel Proficiency Roadmap now. Includes 6 steps for a successful journey, 3 things to avoid, and weekly Excel tips.

Want to learn Excel?

Our training programs start at $29 and will help you learn Excel quickly.

Leave a Comment