求和 IIF 表达式
我试图在 Visual Studio 中对表达式求和,但不断收到 #error,但不知道为什么,因为这是我第一次尝试对表达式求和,之前只在单个字段上完成过。 有什么建议么!!!
=IIf(Fields!STATUS.value = "Completed" AND Fields!DONOTINVOICE.value = True, Fields!ORDERCOST.Value, "")
Im trying to sum an expression in visual studio and just keep getting an #error but not sure why as this si the first time i have tried to sum an expression, only ever done it on a single field before. Any Suggestions!!!
=IIf(Fields!STATUS.value = "Completed" AND Fields!DONOTINVOICE.value = True, Fields!ORDERCOST.Value, "")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
当条件为 false 时,IIf() 的值将计算为字符串 ("")。 你不能对一个字符串求和。 尝试使用 0 代替。
The value of the IIf() will evaluate to a string ("") when your condition is false. You can't sum a string. Try using 0 instead.
你的意思是这样的,只是尝试了一下,然后将所有内容相加就得到 0 :(
=Sum(IIf(Fields!STATUS.value = "Completed" AND Fields!DONOTINVOICE.value = 1, Fields!ORDERCOST.Value, 0))
Do you mean like this, just tried that and dosent sum anything just get 0 :(
=Sum(IIf(Fields!STATUS.value = "Completed" AND Fields!DONOTINVOICE.value = 1, Fields!ORDERCOST.Value, 0))
好吧,无法计算出表达式的总和,因此我只是在新数据集中使用了 case 语句来构建总和功能。 下面的示例,这是在内部查询中,我在主要位中进行了求和。 以防万一其他人遇到这个问题,这就是我解决它的方法。
案件
当 TBL_REPAIR_ORDER.STATUS = '已完成' 并且 TBL_REPAIR_ORDER.DONOTINVOICE = 1 那么 TBL_REPAIR_ORDER.ORDERCOST
其他 0
结束为已完成
Ok couldnt figure out the sum on an expression so ive just used a case statement in a new dataset to build the sum feature. Example below, this is in an inner query and i have done a sum in the main bit. Just incase anyone else gets this issue this is how i resolved it.
CASE
WHEN TBL_REPAIR_ORDER.STATUS = 'Completed' AND TBL_REPAIR_ORDER.DONOTINVOICE = 1 THEN TBL_REPAIR_ORDER.ORDERCOST
ELSE 0
END AS Completed
您必须在值末尾使用“.0”:这确保 if 表达式的返回值不是字符串
You have to use ".0" at the end of value: this make sure that your return value of if expression is not string
对于 Visual Studio,将
IIf
包装在Cdbl
中:For Visual Studio, wrap the
IIf
in aCdbl
: