MS Project自定义域IIf公式仅识别首个判断条件的异常原因是什么?
问题原因
MS Project中日期类型的字段未赋值时,存储的值不是空字符串"",而是特殊的空值标识NA。你使用日期字段和空字符串做不等于判断时,会触发类型不匹配错误,公式的逻辑运算Or遇到错误后会直接短路,后续所有条件都不会执行,默认返回False。
这就是为什么只有排在第一位的判断条件对应的字段有值时,公式才会返回True,其余场景全部返回False。
解决方案
将空值判断逻辑替换为针对日期空值的IsNull函数判断即可,你也可以直接省略外层冗余的IIf包裹,因为逻辑判断本身返回的就是布尔值:
Not IsNull([Baseline Start]) Or Not IsNull([Baseline1 Start]) Or Not IsNull([Baseline2 Start]) Or Not IsNull([Baseline3 Start]) Or Not IsNull([Baseline4 Start]) Or Not IsNull([Baseline5 Start]) Or Not IsNull([Baseline6 Start]) Or Not IsNull([Baseline7 Start]) Or Not IsNull([Baseline8 Start]) Or Not IsNull([Baseline9 Start]) Or Not IsNull([Baseline10 Start])
如果你习惯保留IIf写法,也可以使用以下版本:
IIf( Not IsNull([Baseline Start]) Or Not IsNull([Baseline1 Start]) Or Not IsNull([Baseline2 Start]) Or Not IsNull([Baseline3 Start]) Or Not IsNull([Baseline4 Start]) Or Not IsNull([Baseline5 Start]) Or Not IsNull([Baseline6 Start]) Or Not IsNull([Baseline7 Start]) Or Not IsNull([Baseline8 Start]) Or Not IsNull([Baseline9 Start]) Or Not IsNull([Baseline10 Start]), True, False )
内容的提问来源于stack exchange,提问作者Marc Pincince
相关产品推荐
相关产品推荐

