[excel] excel - if cell is not blank, then do IF statement

I have this simple statement in excel. I compare two dates. If the date 2 is greater than or equal to date 1, then I show 1. If not, then I show 0.

However, I would like to apply this function only when the cells contains text:

IF(NOT(ISBLANK((Q2<=R2;"1";"0")))

That gives me an error - what am I doing wrong?

This question is related to excel

The answer is


You need to use AND statement in your formula

=IF(AND(IF(NOT(ISBLANK(Q2));TRUE;FALSE);Q2<=R2);"1";"0")

And if both conditions are met, return 1.

You could also add more conditions in your AND statement.