0

我试图在 Visual Studio 中对表达式求和,但一直收到 #error 但不知道为什么我第一次尝试对表达式求和,以前只在一个字段上做过。有什么建议么!!!

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

5 回答 5

2

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.

于 2008-12-29T15:06:59.673 回答
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))

于 2008-12-29T15:13:09.723 回答
0
=Sum(IIf(Fields!STATUS.value = "Completed" AND Fields!DONOTINVOICE.value = 1.0, Fields!ORDERCOST.Value, 0.0))

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

于 2014-05-14T07:17:54.703 回答
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

于 2008-12-30T09:21:47.403 回答
0

对于 Visual Studio,将 包装IIfCdbl

=SUM(CDbl(IIf(Fields!STATUS.value = "Completed" AND Fields!DONOTINVOICE.value = True, Fields!ORDERCOST.Value, 0)))
于 2015-02-16T16:59:30.660 回答