我试图在 Visual Studio 中对表达式求和,但一直收到 #error 但不知道为什么我第一次尝试对表达式求和,以前只在一个字段上做过。有什么建议么!!!
=IIf(Fields!STATUS.value = "Completed" AND Fields!DONOTINVOICE.value = True, Fields!ORDERCOST.Value, "")
我试图在 Visual Studio 中对表达式求和,但一直收到 #error 但不知道为什么我第一次尝试对表达式求和,以前只在一个字段上做过。有什么建议么!!!
=IIf(Fields!STATUS.value = "Completed" AND Fields!DONOTINVOICE.value = True, Fields!ORDERCOST.Value, "")
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.
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))
=Sum(IIf(Fields!STATUS.value = "Completed" AND Fields!DONOTINVOICE.value = 1.0, Fields!ORDERCOST.Value, 0.0))
您必须在值的末尾使用“.0”:这确保您的 if 表达式的返回值不是字符串
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
对于 Visual Studio,将 包装IIf
在Cdbl
:
=SUM(CDbl(IIf(Fields!STATUS.value = "Completed" AND Fields!DONOTINVOICE.value = True, Fields!ORDERCOST.Value, 0)))