IF function giving error... do i need to add AND function as well?!

bobletcs123

New Member
Joined
Jan 31, 2019
Messages
27
Office Version
  1. 365
Platform
  1. Windows
Good Morning All,

Having issues with my IF function formula, and i'm sure its user error. For the life of me, can't figure out what issue is and how to resolve. Any help would be greatly appreciated. On my sheet, i'm trying to compare orig dates (Column A) vs actual dates (Column B); easy enough. But, some Column B fields have NA or Complete, which is where i'm running into trouble. My formula is as follows:

=IF(B2-A2>0,"Delay",(IF(B2=A2,"On-Time",(IF(B2-A2<0,"Early",(IF(B2="NA","Open",(IF(B2="Complete","Complete")))))))))

The first part works great, but can't seem to figure out when Column B has NA or Complete. Need NA to generate "Open" and Complete to generate "Complete"...

Thank you in advance!!
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
You need to do the text values first, otherwise you get an error trying to subtract a value from text.
=IF(B2="NA","Open",IF(B2="Complete","Complete",IF(B2-A2>0,"Delay",IF(B2=A2,"On-Time",IF(B2-A2<0,"Early")))))
 
Upvote 0
Reverse the order of your IF statements, as if B2 has "Complete" or "NA" in it, you won't be able to do the math, and that can cause errors.
So check for that first, i.e.
Code:
=IF(B2="Complete","Complete",IF(B2="NA","Open",IF(B2-A2>0,"Delay",IF(B2-A2<0,"Early","On-Time"))))


EDIT: I am not quite as quick as Fluff this morning!
 
Last edited:
Upvote 0
You could also use
=IF(B2="NA","Open",IF(B2="Complete","Complete",CHOOSE(SIGN(B2-A2)+2,"Early","On-Time","Delay")))
which saves calculating B2 & A2 three times.
 
Last edited:
Upvote 0
Aghh! Stupid mistake :/ Thank you both so much!!.... coffee hasn't kicked in yet :)
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,894
Messages
6,122,124
Members
449,066
Latest member
Andyg666

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top