A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data
Use a lookup table instead of a long nested IF, then apply a simple formula that checks the three cases in order.
- Create a table for the 1st criterion (groups)
- On another sheet, list the 9 qualifying groups in a single column (for example, in
Groups!A2:A10). - Format it as a table if desired (for easier maintenance), but a simple range also works.
- On another sheet, list the 9 qualifying groups in a single column (for example, in
- Formula logic
Assume:
-
A2= Group for the row -
B2= Product for the row -
C2= Sales amount -
Groups!A2:A10= list of groups that qualify for 2% -
"ProductX"= the specific product that qualifies for 1%
Explanation:=IF(COUNTIF(Groups!$A$2:$A$10, A2)>0, C2*2%, IF(B2="ProductX", C2*1%, C2*5% ) )-
COUNTIF(Groups!$A$2:$A$10, A2)>0checks whether the group inA2is in the list of 9 groups. If yes → 2% of sales. - If not in the group list,
IF(B2="ProductX", …)checks whether the specific product was bought. If yes → 1% of sales. - Otherwise → 5% of sales.
-
- Why this is easier to maintain
- To add or remove qualifying groups, just edit the list in
Groups!A2:A10; no formula changes are needed. - The main formula stays short and readable compared to a long nested IF with 9 group checks.
- To add or remove qualifying groups, just edit the list in
If there are many bands or more complex conditions later, consider moving more logic into lookup tables and using functions like VLOOKUP or XLOOKUP instead of expanding the IF.
References: