Excel · ChatGPT

Write IF, IFS and Nested IF Formulas in Excel with ChatGPT

Grading scales, bonus tiers, payroll rules — they all start the same way: "if this, then that". Describe your logic as a plain list and ChatGPT writes a clean IF or IFS formula, chooses the right function for your Excel version, and adds the default case most people forget.

Choose your situation — copy the prompt:
I need an IF or IFS formula in Excel. The score being tested is in cell B2.
Valid scores are numbers from 0 to 100.

Here's the logic:
- 90 to 100 → "A"
- 80 to 89.999... → "B"
- 70 to 79.999... → "C"
- 0 to 69.999... → "Fail"

I'm using Excel [Microsoft 365 / Excel 2024 / Excel 2021 / Excel 2019 / Excel 2016].
Please use IFS if my version supports it; otherwise use nested IF.
Return "Invalid" for blanks, text, negative numbers, or scores above 100.

Replace the logic and cell reference with your own, then paste the prompt into ChatGPT.

My nested IF formula is giving wrong results. Here's the formula:
[paste formula]

When the value in the test cell is [value], it returns [wrong result]
instead of [expected result].
I'm using Excel [Microsoft 365 / Excel 2024 / Excel 2021 / Excel 2019 / Excel 2016].

Please identify the logic error, explain why it happens, and give me a
corrected formula that works in my Excel version.

Wrong results at a boundary value (e.g. exactly 80) almost always mean a > vs >= mistake.

I need an IF or IFS formula for bonus calculation. Performance score is in
C2 and base salary is in D2. Valid scores are whole numbers from 1 to 5.

Rules:
- Score 5 → 20% of salary
- Score 4 → 10% of salary
- Score 3 → 5% of salary
- Score 1 or 2 → no bonus

I'm using Excel [Microsoft 365 / Excel 2024 / Excel 2021 / Excel 2019 / Excel 2016].
Please calculate the bonus amount and return "CHECK SCORE" if C2 is blank,
text, outside 1–5, or not a whole number.

Make sure the validation does not evaluate numeric functions such as INT, MOD,
or arithmetic comparisons on text or blank inputs before confirming that C2
contains a number.

Swap in your own score-to-percentage rules — ChatGPT keeps the structure, you change the numbers.

Before — nested IF is hard to audit
Microsoft Excel
C2
fx
=IF(B2>=90,"A",IF(B2>=80,"B",IF(B2>=70,"C","Fail")))
A
B
C
D
1
Student
Score
Grade formula
Result
2
A. Morris
94
=IF(B2>=90,"A",IF(B2>=80,"B",IF(B2>=70,"C","Fail")))
A
3
B. Chen
83
filled down
B
4
C. Singh
71
filled down
C
5
D. Okafor
58
filled down
Fail
The nested IF grades valid numeric scores correctly, but it has no explicit validation for blanks, text, negative scores, or values above 100.
After — cleaner IFS plus input validation
Microsoft Excel
C2
fx
=IF(OR(NOT(ISNUMBER(B2)),B2<0,B2>100),"Invalid",IFS(B2>=90,"A",B2>=80,"B",B2>=70,"C",TRUE,"Fail"))
A
B
C
D
1
Student
Score
IFS formula
Grade
2
A. Morris
94
=IF(OR(NOT(ISNUMBER(B2)),B2<0,B2>100),"Invalid",IFS(B2>=90,"A",B2>=80,"B",B2>=70,"C",TRUE,"Fail"))
A
3
B. Chen
83
filled down
B
4
C. Singh
71
filled down
C
5
D. Okafor
58
filled down
Fail
ChatGPT's formula
=IF(OR(NOT(ISNUMBER(B2)),B2<0,B2>100),"Invalid",
   IFS(B2>=90,"A",B2>=80,"B",B2>=70,"C",TRUE,"Fail"))

Valid range: 0–100. Unexpected inputs are flagged instead of silently graded.
Before — 90 is incorrectly graded B
Microsoft Excel
C3
fx
=IF(B3>90,"A",IF(B3>80,"B",IF(B3>70,"C","Fail")))
A
B
C
D
1
Student
Score
Grade
Expected
2
A. Morris
95
A
A
3
B. Chen
90
B
A
4
C. Singh
80
C
B
5
D. Okafor
70
Fail
C
6
E. Patel
65
Fail
Fail
The formula uses strict >. Exact cutoffs 90, 80 and 70 fall into the next bucket down.
After — same nested IF, corrected boundaries
Microsoft Excel
C3
fx
=IF(B3>=90,"A",IF(B3>=80,"B",IF(B3>=70,"C","Fail")))
A
B
C
D
1
Student
Score
Grade
Expected
2
A. Morris
95
A
A
3
B. Chen
90
A
A
4
C. Singh
80
B
B
5
D. Okafor
70
C
C
6
E. Patel
65
Fail
Fail
ChatGPT's fix
=IF(B3>=90,"A",IF(B3>=80,"B",IF(B3>=70,"C","Fail")))
Only the boundary operators changed: > became >=.
90 → A · 80 → B · 70 → C ✓
Before — bonus amount is still manual
Microsoft Excel
F2
fx
A
B
C
D
E
F
1
Employee
Dept
Score
Salary
Bonus %
Bonus £
2
Adams, J.
Sales
5
£48,000
20%
Manual
3
Bell, K.
Finance
4
£52,000
10%
Manual
4
Chen, L.
HR
3
£38,000
5%
Manual
5
Davis, M.
Ops
2
£41,000
0%
Manual
6
Evans, P.
Sales
1
£44,500
0%
Manual
Column F has no formula, so payouts are calculated manually and invalid performance scores are not automatically flagged.
After — one formula calculates every payout
Microsoft Excel
F2
fx
=IF(NOT(ISNUMBER(C2)),"CHECK SCORE",IF(OR(C2<1,C2>5,C2<>INT(C2)),"CHECK SCORE",IFS(C2=5,D2*20%,C2=4,D2*10%,C2=3,D2*5%,TRUE,0)))
A
C
D
E
F
1
Employee
Score
Salary
Bonus %
Bonus £
2
Adams, J.
5
£48,000
20%
£9,600
3
Bell, K.
4
£52,000
10%
£5,200
4
Chen, L.
3
£38,000
5%
£1,900
5
Davis, M.
2
£41,000
0%
£0
6
Evans, P.
1
£44,500
0%
£0
7
Total
£16,700
ChatGPT's formula — F2
=IF(NOT(ISNUMBER(C2)),"CHECK SCORE",
   IF(OR(C2<1,C2>5,C2<>INT(C2)),"CHECK SCORE",
      IFS(C2=5,D2*20%,C2=4,D2*10%,C2=3,D2*5%,TRUE,0)))

Fill down through F6.
£9,600 + £5,200 + £1,900 + £0 + £0 = £16,700 ✓
Why IF formulas break — the 4 most common causes
> vs >= at boundary
Exact value 80 falls into wrong bucket because of one operator
Most common
Missing default case
IFS with no final default can return #N/A when every logical test is FALSE
Most common
Too many nested IFs
5+ nested IFs become unreadable — one bracket slip breaks everything
Easy fix
IFS on old Excel
IFS is supported in Microsoft 365 and Excel 2019, 2021 and 2024 — nested IF is the fallback on Excel 2016
Invisible

How to build IF and IFS formulas step by step

Write and test an IF or IFS formula with ChatGPT — 5 steps
1

Write the logic as a simple list first

Before opening ChatGPT, list your conditions clearly — 90 or above → A, 80 or above → B, and so on. This list becomes your prompt. The clearer the list, the better the formula.

2

Tell ChatGPT your Excel version and the cell to test

IFS is available in Microsoft 365 and Excel 2019, 2021 and 2024. Also specify exactly which cell contains the value being tested — for example "the score is in B2" — so the formula is ready to paste directly.

3

Read the explanation, not just the formula

ChatGPT explains each condition in plain English alongside the formula. Read it — this is the best way to catch a logic error like a > that should be >= before it spreads across your data.

4

Test at the exact boundary values

Always test with the cutoff values themselves — 90, 80, 70, 69. Boundary cases are where IF formulas most often fail. One character makes the difference.

5

Add a safety net for unexpected values

Make sure the formula handles edge cases explicitly — blank cells, text in a numeric field, and values outside the valid range. Use validation tests and a final default result where appropriate; do not use IFERROR merely to hide a logic or input error.

Multiple errors? If you have several IF-related issues in one sheet, fix them one at a time. After each fix, re-check the results — Excel sometimes reveals a second problem only after the first one is resolved.

Frequently asked questions

What is the difference between IF and IFS in Excel?
IF is a traditional function that can be nested to handle multiple conditions, while IFS allows you to test multiple conditions without nesting, making the formula much cleaner and easier to read.
How many IF statements can you nest in Excel?
Excel allows formulas to nest functions up to 64 levels, but deeply nested IF formulas quickly become difficult to debug and maintain. Use IFS, VLOOKUP, or XLOOKUP instead.
How do I build a bonus tier calculation in Excel?
You can build a bonus tier calculation using an IFS function or a VLOOKUP/XLOOKUP table. Use IFS if your tiers are simple ranges, or a lookup table if your tiers change frequently.
Does IFS have a built-in else condition?
No. IFS has no built-in "else" argument. To handle values that match none of your conditions, add TRUE,"—" (or another default result) as the final pair. If every logical test is FALSE and there is no default pair, IFS returns #N/A.
Which Excel versions support IFS?
IFS is available in Microsoft 365 and Excel 2019, 2021 and 2024. It is not available in Excel 2016, so use nested IF there — tell ChatGPT which version you're using so the formula stays compatible.

Related Excel workflows