求和 IIF 表达式

发布于 2024-07-10 17:49:58 字数 228 浏览 10 评论 0原文

我试图在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

风尘浪孓 2024-07-17 17:49:58

当条件为 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.

抠脚大汉 2024-07-17 17:49:58

你的意思是这样的,只是尝试了一下,然后将所有内容相加就得到 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))

青衫儰鉨ミ守葔 2024-07-17 17:49:58

好吧,无法计算出表达式的总和,因此我只是在新数据集中使用了 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

这个俗人 2024-07-17 17:49:58
=Sum(IIf(Fields!STATUS.value = "Completed" AND Fields!DONOTINVOICE.value = 1.0, Fields!ORDERCOST.Value, 0.0))

您必须在值末尾使用“.0”:这确保 if 表达式的返回值不是字符串

=Sum(IIf(Fields!STATUS.value = "Completed" AND Fields!DONOTINVOICE.value = 1.0, Fields!ORDERCOST.Value, 0.0))

You have to use ".0" at the end of value: this make sure that your return value of if expression is not string

将军与妓 2024-07-17 17:49:58

对于 Visual Studio,将 IIf 包装在 Cdbl 中:

=SUM(CDbl(IIf(Fields!STATUS.value = "Completed" AND Fields!DONOTINVOICE.value = True, Fields!ORDERCOST.Value, 0)))

For Visual Studio, wrap the IIf in a Cdbl:

=SUM(CDbl(IIf(Fields!STATUS.value = "Completed" AND Fields!DONOTINVOICE.value = True, Fields!ORDERCOST.Value, 0)))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文