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.
我在excel中有这个简单的陈述。我比较两个日期。如果日期2大于或等于日期1,那么我显示1.如果不是,那么我显示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?
这给了我一个错误 - 我做错了什么?
2 个解决方案
#1
10
Your formula is wrong. You probably meant something like:
你的公式错了。你可能意味着:
=IF(AND(NOT(ISBLANK(Q2));NOT(ISBLANK(R2)));IF(Q2<=R2;"1";"0");"")
Another equivalent:
另一个等价物
=IF(NOT(OR(ISBLANK(Q2);ISBLANK(R2)));IF(Q2<=R2;"1";"0");"")
Or even shorter:
甚至更短:
=IF(OR(ISBLANK(Q2);ISBLANK(R2));"";IF(Q2<=R2;"1";"0"))
OR EVEN SHORTER:
或者甚至更短的:
=IF(OR(ISBLANK(Q2);ISBLANK(R2));"";--(Q2<=R2))
#2
1
You need to use AND statement in your formula
您需要在公式中使用AND语句
=IF(AND(IF(NOT(ISBLANK(Q2));TRUE;FALSE);Q2<=R2);"1";"0")
= IF(AND(IF(NOT(ISBLANK(Q2)); TRUE; FALSE); Q2 <= R2); “1”; “0”)
And if both conditions are met, return 1.
如果两个条件都满足,则返回1。
You could also add more conditions in your AND statement.
您还可以在AND语句中添加更多条件。
#1
10
Your formula is wrong. You probably meant something like:
你的公式错了。你可能意味着:
=IF(AND(NOT(ISBLANK(Q2));NOT(ISBLANK(R2)));IF(Q2<=R2;"1";"0");"")
Another equivalent:
另一个等价物
=IF(NOT(OR(ISBLANK(Q2);ISBLANK(R2)));IF(Q2<=R2;"1";"0");"")
Or even shorter:
甚至更短:
=IF(OR(ISBLANK(Q2);ISBLANK(R2));"";IF(Q2<=R2;"1";"0"))
OR EVEN SHORTER:
或者甚至更短的:
=IF(OR(ISBLANK(Q2);ISBLANK(R2));"";--(Q2<=R2))
#2
1
You need to use AND statement in your formula
您需要在公式中使用AND语句
=IF(AND(IF(NOT(ISBLANK(Q2));TRUE;FALSE);Q2<=R2);"1";"0")
= IF(AND(IF(NOT(ISBLANK(Q2)); TRUE; FALSE); Q2 <= R2); “1”; “0”)
And if both conditions are met, return 1.
如果两个条件都满足,则返回1。
You could also add more conditions in your AND statement.
您还可以在AND语句中添加更多条件。