Introduction
Excel formulas sometimes return errors when data is missing, incorrect, or does not match the expected condition. IFERROR, IFNA, and SWITCH help you handle these situations and make worksheets easier to understand. In this chapter, you will practice these functions using different examples involving calculations, lookups, grades, departments, product categories, and status values. Excel-IFERROR IFNA and SWITCH practice questions with solutions to help you understand the concepts.
Question 1: Handle Division by Zero with IFERROR
Problem Statement
Calculate the sales per employee. Some departments have zero employees, which causes a #DIV/0! error. Use IFERROR to display "No Employees" instead of the error.
Excel Data
| Department | Sales | Employees | Sales per Employee |
|---|---|---|---|
| IT | 500000 | 10 | |
| HR | 250000 | 5 | |
| Finance | 300000 | 0 | |
| Marketing | 450000 | 9 | |
| Sales | 600000 | 12 |
Solution
In D2, enter:
=IFERROR(B2/C2,"No Employees")
Copy the formula down.
Expected Output
| Department | Sales | Employees | Sales per Employee |
|---|---|---|---|
| IT | 500000 | 10 | 50000 |
| HR | 250000 | 5 | 50000 |
| Finance | 300000 | 0 | No Employees |
| Marketing | 450000 | 9 | 50000 |
| Sales | 600000 | 12 | 50000 |
Question 2: Handle Missing Lookup Results with IFNA
Problem Statement
Use VLOOKUP to find the price of each product. If a product does not exist in the price list, display "Product Not Found" instead of #N/A.
Price List
| Product | Price |
|---|---|
| Laptop | 55000 |
| Monitor | 12000 |
| Keyboard | 850 |
| Mouse | 550 |
| Printer | 15000 |
Search Data
| Product | Price |
|---|---|
| Laptop | |
| Mouse | |
| Webcam | |
| Printer | |
| Speaker |
Solution
Assume the price list is in F2:G6.
In B2, enter:
=IFNA(VLOOKUP(A2,$F$2:$G$6,2,FALSE),"Product Not Found")
Copy the formula down.
Expected Output
| Product | Price |
|---|---|
| Laptop | 55000 |
| Mouse | 550 |
| Webcam | Product Not Found |
| Printer | 15000 |
| Speaker | Product Not Found |
IFNA specifically handles the #N/A error.
Question 3: Use IFERROR with a Percentage Calculation
Problem Statement
Calculate the percentage of completed orders. Some records have zero total orders. Display "No Orders" when the calculation produces an error.
Excel Data
| Employee | Completed Orders | Total Orders | Completion % |
|---|---|---|---|
| Rahul | 45 | 50 | |
| Priya | 38 | 40 | |
| Amit | 0 | 0 | |
| Neha | 72 | 80 | |
| Arjun | 25 | 30 |
Solution
In D2, enter:
=IFERROR(B2/C2,"No Orders")
Format the result column as Percentage and copy the formula down.
Expected Output
| Employee | Completed Orders | Total Orders | Completion % |
|---|---|---|---|
| Rahul | 45 | 50 | 90% |
| Priya | 38 | 40 | 95% |
| Amit | 0 | 0 | No Orders |
| Neha | 72 | 80 | 90% |
| Arjun | 25 | 30 | 83.33% |
Question 4: Use SWITCH to Convert Department Codes into Names
Problem Statement
A company stores department information using short codes:
ITHRFNMKSL
Use SWITCH to display the full department name.
Excel Data
| Employee | Department Code | Department Name |
|---|---|---|
| Rahul | IT | |
| Priya | HR | |
| Amit | FN | |
| Neha | MK | |
| Arjun | SL |
Solution
In C2, enter:
=SWITCH(B2,"IT","Information Technology","HR","Human Resources","FN","Finance","MK","Marketing","SL","Sales","Unknown")
Copy the formula down.
Expected Output
| Employee | Department Code | Department Name |
|---|---|---|
| Rahul | IT | Information Technology |
| Priya | HR | Human Resources |
| Amit | FN | Finance |
| Neha | MK | Marketing |
| Arjun | SL | Sales |
The final "Unknown" acts as the default result if none of the codes match.
Question 5: Use SWITCH to Convert Grades into Descriptions
Problem Statement
A school uses the following grade system:
| Grade | Description |
|---|---|
| A | Excellent |
| B | Very Good |
| C | Good |
| D | Needs Improvement |
| F | Fail |
Use SWITCH to automatically display the description.
Excel Data
| Student | Grade | Description |
|---|---|---|
| Rahul | A | |
| Priya | B | |
| Amit | C | |
| Neha | A | |
| Arjun | D | |
| Simran | F |
Solution
In C2, enter:
=SWITCH(B2,"A","Excellent","B","Very Good","C","Good","D","Needs Improvement","F","Fail","Invalid Grade")
Copy down.
Expected Output
| Student | Grade | Description |
|---|---|---|
| Rahul | A | Excellent |
| Priya | B | Very Good |
| Amit | C | Good |
| Neha | A | Excellent |
| Arjun | D | Needs Improvement |
| Simran | F | Fail |
Question 6: Use IFERROR with a Discount Calculation
Problem Statement
Calculate the discount percentage for each order using:
Discount ÷ Original Price
Some orders have an original price of zero. Use IFERROR to display "Not Available".
Excel Data
| Order | Original Price | Discount | Discount % |
|---|---|---|---|
| O101 | 5000 | 500 | |
| O102 | 8000 | 800 | |
| O103 | 0 | 0 | |
| O104 | 12000 | 1800 | |
| O105 | 6000 | 300 |
Solution
In D2, enter:
=IFERROR(C2/B2,"Not Available")
Format the column as Percentage.
Expected Output
| Order | Original Price | Discount | Discount % |
|---|---|---|---|
| O101 | 5000 | 500 | 10% |
| O102 | 8000 | 800 | 10% |
| O103 | 0 | 0 | Not Available |
| O104 | 12000 | 1800 | 15% |
| O105 | 6000 | 300 | 5% |
Question 7: Use IFNA with XLOOKUP
Problem Statement
Use XLOOKUP to find the employee’s department. If the employee ID does not exist, display "Employee Not Found".
Employee Data
| Employee ID | Employee | Department |
|---|---|---|
| E101 | Rahul | IT |
| E102 | Priya | HR |
| E103 | Amit | Finance |
| E104 | Neha | Marketing |
| E105 | Arjun | Sales |
Search Data
| Employee ID | Department |
|---|---|
| E101 | |
| E103 | |
| E106 | |
| E105 | |
| E110 |
Solution
Assume employee IDs are in A2:A6 and departments are in C2:C6.
In B2, enter:
=IFNA(XLOOKUP(A2,$A$2:$A$6,$C$2:$C$6),"Employee Not Found")
Copy the formula down.
Expected Output
| Employee ID | Department |
|---|---|
| E101 | IT |
| E103 | Finance |
| E106 | Employee Not Found |
| E105 | Sales |
| E110 | Employee Not Found |
Question 8: Use SWITCH with Numeric Values
Problem Statement
A customer support system assigns priority levels using numbers:
1= Low2= Medium3= High4= Critical
Use SWITCH to display the priority name.
Excel Data
| Ticket | Priority Code | Priority |
|---|---|---|
| T101 | 1 | |
| T102 | 3 | |
| T103 | 4 | |
| T104 | 2 | |
| T105 | 3 |
Solution
In C2, enter:
=SWITCH(B2,1,"Low",2,"Medium",3,"High",4,"Critical","Invalid Code")
Copy down.
Expected Output
| Ticket | Priority Code | Priority |
|---|---|---|
| T101 | 1 | Low |
| T102 | 3 | High |
| T103 | 4 | Critical |
| T104 | 2 | Medium |
| T105 | 3 | High |
Question 9: Combine IFERROR with IF
Problem Statement
Calculate the average sales per order. If the number of orders is zero, display "No Orders". If the average is at least ₹5,000, display "Good"; otherwise display "Low".
Excel Data
| Salesperson | Total Sales | Orders | Performance |
|---|---|---|---|
| Rahul | 250000 | 40 | |
| Priya | 180000 | 30 | |
| Amit | 0 | 0 | |
| Neha | 360000 | 60 | |
| Arjun | 120000 | 30 |
Solution
In D2, enter:
=IFERROR(IF(B2/C2>=5000,"Good","Low"),"No Orders")
Copy down.
Expected Output
| Salesperson | Total Sales | Orders | Performance |
|---|---|---|---|
| Rahul | 250000 | 40 | Good |
| Priya | 180000 | 30 | Good |
| Amit | 0 | 0 | No Orders |
| Neha | 360000 | 60 | Good |
| Arjun | 120000 | 30 | Low |
This example shows how IFERROR can wrap another formula containing IF.
Question 10: Build a Practical Order Status System with SWITCH and IFERROR
Problem Statement
Create an order status report using an order status code:
1= Processing2= Shipped3= Delivered4= Cancelled
The system should display "Unknown Status" when an invalid code is entered.
Also calculate the Amount per Item using Total Amount ÷ Quantity. If Quantity is zero, display "Invalid Quantity".
Excel Data
| Order ID | Status Code | Quantity | Total Amount | Order Status | Amount per Item |
|---|---|---|---|---|---|
| O101 | 1 | 5 | 5000 | ||
| O102 | 2 | 4 | 8000 | ||
| O103 | 3 | 10 | 15000 | ||
| O104 | 4 | 2 | 3000 | ||
| O105 | 5 | 0 | 5000 |
Solution
Step 1: Convert Status Code
In E2, enter:
=SWITCH(B2,1,"Processing",2,"Shipped",3,"Delivered",4,"Cancelled","Unknown Status")
Copy down.
Step 2: Calculate Amount per Item
In F2, enter:
=IFERROR(D2/C2,"Invalid Quantity")
Copy down.
Expected Output
| Order ID | Status Code | Quantity | Total Amount | Order Status | Amount per Item |
|---|---|---|---|---|---|
| O101 | 1 | 5 | 5000 | Processing | 1000 |
| O102 | 2 | 4 | 8000 | Shipped | 2000 |
| O103 | 3 | 10 | 15000 | Delivered | 1500 |
| O104 | 4 | 2 | 3000 | Cancelled | 1500 |
| O105 | 5 | 0 | 5000 | Unknown Status | Invalid Quantity |
This question combines SWITCH and IFERROR in a practical order-management example.
Key Takeaways
IFERRORlets you replace an Excel error with a meaningful result.IFNAspecifically handles the#N/Aerror.SWITCHcompares one value against multiple possible values.IFERRORis useful for calculations involving division by zero.IFNAis especially useful with lookup functions such asVLOOKUPandXLOOKUP.SWITCHcan work with both text and numeric values.- A default value can be added to
SWITCHwhen none of the cases match. IFERRORcan contain anotherIFformula.- These functions can make reports cleaner and easier for other users to understand.
- Error handling should provide a meaningful message instead of simply hiding problems in the data.
FAQs
1. What is IFERROR in Excel?
IFERROR checks whether a formula produces an error. If an error occurs, it returns the value you specify.
=IFERROR(A2/B2,"Not Available")
2. What is IFNA in Excel?
IFNA handles the #N/A error specifically.
=IFNA(VLOOKUP(A2,F:G,2,FALSE),"Not Found")
3. What is the difference between IFERROR and IFNA?
IFERROR handles many types of Excel errors, while IFNA handles only the #N/A error.
4. When should I use IFNA instead of IFERROR?
Use IFNA when #N/A is the specific error you expect, especially when working with lookup formulas.
5. What does SWITCH do in Excel?
SWITCH compares one expression against several values and returns the result associated with the matching value.
=SWITCH(A2,1,"Low",2,"Medium",3,"High","Unknown")
6. Can SWITCH use text values?
Yes. For example:
=SWITCH(A2,"IT","Technology","HR","Human Resources","Other")
7. Can SWITCH use numbers?
Yes. Numeric values can be used as the cases in a SWITCH formula.
8. Can IFERROR be combined with IF?
Yes. For example:
=IFERROR(IF(B2/C2>=5000,"Good","Low"),"No Orders")
9. Can IFNA be used with XLOOKUP?
Yes. It can be used to replace the #N/A result when XLOOKUP cannot find a matching value.
10. Why should I use error-handling functions in Excel?
They prevent confusing error messages from appearing in reports and allow you to display useful messages such as "Not Found", "No Orders", or "Invalid Quantity".
Written by Shubhranshu Shekhar, who has trained 20000+ students in coding.
