SOLVED

if statement for multiple date conditions

Copper Contributor

I'm looking to create an if statement that returns the 4 scenarios listed below. The highlighted scenarios in red are where I seem to be having difficulties.

 

Confirmed Late = Actual Delivery is after Target Delivery

Unconfirmed Late = Actual Delivery is blank and the current date is after Target Delivery

On Time = Actual Deliver is before Target Delivery

In Transit = Actual Delivery is blank and the current date is before Target Delivery

 

My current formula:

 

=IF([@[Actual Delivery]]>=[@[Target Delivery (Late)]], "Confirmed Late", IF([@[Actual Delivery]]<[@[Target Delivery (Late)]],"On Time", ""))

 

Data sample attached - any help would be greatly appreciated!!

 

9 Replies

@ncstle 

The main problem is that columns A and B contain text values that look like dates, not real dates. A tell-tale sign is that they are left-aligned.

Once you have corrected that, you can use the formula

 

=IF([@[Actual Delivery]]="",IF([@[Target Delivery (Late)]]>NOW(),"In Transit","Unconfirmed Late"),IF([@[Actual Delivery]]<=[@[Target Delivery (Late)]],"On Time","Confirmed Late"))

@ncstle 

Perhaps

=IF([@[Actual Delivery]]="",
     IF(NOW()<[@[Target Delivery (Late)]],"In Transit","Uncomfird late"),
     IF([@[Actual Delivery]]<[@[Target Delivery (Late)]],"On Time","Confirmed late")
)

@Hans Vogelaar 

 

Hi thanks for the insight, I've corrected the dates! The formula provided seems to get me most of the way there but appears to miss the "unconfirmed late" piece.

 

The highlighted fields in the screenshot are returning as In Transit but should flag as Unconfirmed late because it is now after the Target Delivery Date.

 

ncstle_0-1619731003131.png

 

@Sergei Baklan 


I went ahead and tried this formula but it seems to be missing the "Unconfirmed Late" flag. he highlighted fields in the screenshot are returning as In Transit but should flag as Unconfirmed late because it is now after the Target Delivery Date.

 

ncstle_0-1619731121644.png

 

@ncstle 

The dates are still left-aligned, so I suspect they are still text values instead of dates.

@Hans Vogelaar the dates aren't text values, they're in date format. I've attached the file for reference. 

@ncstle 

They ARE text values, not dates, even though they look like dates and the number format is Date. You can see this because the values are left-aligned while horizontal alignment is set to General. Real dates are right-aligned. And the formula =ISTEXT([@[Target Delivery (Late)]]) returns TRUE:

 

S0354.png

 

Your formulas won't work correctly until you have converted the text values to real date/time values. You might try the following:

Enter 1 in an empty cell.

Copy it.

Select the target delivery values.

Right-click in the selection and select Paste Special...

Select Multiply and click OK.

If necessary, apply a date+time format.

Does that make the values right-aligned?

If so, you can do the same for the actual delivery values. Make sure not to include the empty cells.

That makes sense. Apologies for not understanding. I tried the conversion that you gave me and it didn't change the values to right aligned. I've also alternatively tried the text to columns way to format and have had no luck :\

This seemingly simple task has been the bane of my existence.
best response confirmed by ncstle (Copper Contributor)
Solution

@ncstle 

The problem was that Excel expects a space before AM/PM. I have converted the values for you - see attached.

1 best response

Accepted Solutions
best response confirmed by ncstle (Copper Contributor)
Solution

@ncstle 

The problem was that Excel expects a space before AM/PM. I have converted the values for you - see attached.

View solution in original post