这里有一个小问题。
我在报告中具有Switch
函数,如下所示:
=Switch(
Fields!Duration.Value > 0, Round(Fields!Duration.Value / 60),
Fields!LastTime.Value = nothing, "Still Occupied",
Fields!LastTime.Value = Fields!FirstTime.Value, "Passing By"
)
这是一列,以分钟为单位显示“ Fields!Duration.Value”的总数(四舍五入),除了第二行以外,它还在工作:
如果“ Last Time”值与“ First Time”值相同,则假定该对象刚刚经过并输出“ Passing By”,并且可以正确执行此操作。
但是,如果“ Last Time”值等于“ no”(在“ Last Time”列中定义,则为“ Nothing”,则为“ nothing”,并且应在此报告中输出“ Still Occupied”)单元格留空,好像我写成Fields!LastTime.Value = nothing, nothing,
为什么这行代码不起作用?
Fields!LastTime.Value = nothing, "Still Occupied",
谢谢
答案 0 :(得分:3)
您不能使用=运算符测试Nothing。没有什么可以测试的方法有两种:使用类似IsNothing(Fields!LastTime.Value) = True
的IsNothing检查函数,或使用类似Fields!LastTime.Value Is Nothing
的Is操作符。
如果这些测试未产生预期的结果,则可能是因为您处理的字段设置为NULL以外的其他值,例如empty或任意值。您可以在数据集属性上打开查询设计器以运行查询并检查结果。
您也可能正在查看数据集的错误映射。使用“数据集”属性上的“刷新字段”按钮来验证“字段映射”,然后再次检查表达式中使用的名称是否匹配。
答案 1 :(得分:0)
I found that using an IIF statement instead of a Switch statement worked for me, at least for this specific case:
=IIF(Fields!Duration.Value > 0, Round(Fields!Duration.Value / 60),
IIF(Fields!LastTime.Value = Fields!FirstTime.Value, "Passing by", "Still Occupied"))
Going to try to explain it for future people that might not understand (like me when I eventually forget it - I am very new to this sort of stuff) -
Rather than using the Switch
statement I had in place to see if Fields!LastTime.Value
is a number, equal to Fields!FirstTime.Value, or nothing, it now just asks if it is a number or if it is equal to Fields!FirstTime.Value
, and if neither of those are true, it marks it as "Still Occupied" thus removing the need to reference nothing
entirely. Like I said, this is pretty case specific, but you never know.
Thank you for the help @JamieSee and @SuperSimmer 44. Cheers!
答案 2 :(得分:-3)
可能是“”周围没有任何东西