Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
If statement 为什么Google Sheets IF语句返回“返回”#“价值”;而不是",;0“;_If Statement_Google Sheets_Google Sheets Formula - Fatal编程技术网

If statement 为什么Google Sheets IF语句返回“返回”#“价值”;而不是",;0“;

If statement 为什么Google Sheets IF语句返回“返回”#“价值”;而不是",;0“;,if-statement,google-sheets,google-sheets-formula,If Statement,Google Sheets,Google Sheets Formula,在我的谷歌工作表中,我有一个非常简单的IF语句: =IF(SEARCH("PM",K2)>0,1,0) 基本上,我是问K2单元中是否有“PM”。K2是“H:MM:SS AM/PM”格式的时间。当返回true时,它给我一个值“1”,否则它给我“#value”,错误为 在搜索评估中,在“8:02:48 AM”内找不到“PM” 为什么它不返回“0”?这就是它的工作原理。它返回#值如果找不到字符串。如果你想要一个0,我建议 =IFERROR(N(SEARCH("AM

在我的谷歌工作表中,我有一个非常简单的IF语句:

=IF(SEARCH("PM",K2)>0,1,0)
基本上,我是问K2单元中是否有“PM”。K2是“H:MM:SS AM/PM”格式的时间。当返回true时,它给我一个值“1”,否则它给我“#value”,错误为

在搜索评估中,在“8:02:48 AM”内找不到“PM”

为什么它不返回“0”?

这就是它的工作原理。它返回
#值如果找不到字符串。如果你想要一个0,我建议

=IFERROR(N(SEARCH("AM",K2)>0),0)
N
用于一致的数据键入。或者更简短地说:

=IFERROR(1^SEARCH("PM",K2),0)
=IFERROR(SEARCH("PM",K2)^0,0)
这就是工作原理。它返回
#值如果找不到字符串。如果你想要一个0,我建议

=IFERROR(N(SEARCH("AM",K2)>0),0)
N
用于一致的数据键入。或者更简短地说:

=IFERROR(1^SEARCH("PM",K2),0)
=IFERROR(SEARCH("PM",K2)^0,0)