简体   繁体   English

SSRS 报告中定义的表达式显示 #ERROR

[英]Defined expression in SSRS report is displaying #ERROR

I have defined an expression in one of my cells from my dataset1 .我已经在我的dataset1中的一个单元格中定义了一个表达式。 My Design window and I have to repeat for each month's cells but I'm getting an #ERROR when I click on the PREVIEW tab in SSRS.我的设计窗口和我必须对每个月的单元格重复,但是当我单击 SSRS 中的“ PREVIEW选项卡时出现 #ERROR。

My thought is if the ActivityMonth value = 1 and the Type value = "PIF" then display the value in the Data column.我的想法是,如果ActivityMonth value = 1Type value = "PIF"则在数据列中显示该值。

=IIF(Fields!Activity_Month.Value = 1 AND Fields!Type.Value = "PIF", Fields!Data.Value, 0)

I got this WARNING from SSRS:我收到了来自 SSRS 的警告:

[rsRuntimeErrorInExpression] The Value expression for the textrun 'Textbox1471.Paragraphs[0].TextRuns[0]' contains an error: Input string was not in a correct format. [rsRuntimeErrorInExpression] textrun 'Textbox1471.Paragraphs[0].TextRuns[0]' 的值表达式包含错误:输入字符串的格式不正确。

But it ran successfully.但它运行成功。

From the comments and the edit history, it looks like you have used & mark which is used to concatenate strings instead of AND keyword.从评论和编辑历史来看,您似乎使用了&标记,它用于连接字符串而不是AND关键字。 After editing the expression - for me - the following expression looks great:编辑表达式后 - 对我来说 - 以下表达式看起来很棒:

 =IIF(Fields!Activity_Month.Value = 1 AND Fields!Type.Value = "PIF", Fields!Data.Value, 0)

But i have two remarks:但我有两点说明:

It may cause an error due to the different data types returned by the expression ( 0 is integer, Data.Value has another data type:由于表达式返回的数据类型不同,可能会导致错误( 0是整数, Data.Value有另一种数据类型:

If Fields!Data.Value is of type string then use the following expression:如果Fields!Data.Value是字符串类型,则使用以下表达式:

 =IIF(Fields!Activity_Month.Value = 1 AND Fields!Type.Value = "PIF", Fields!Data.Value, "0")

Another thing to mention is that if value contains null it may throw an exception, so you have to check if field contains null:另一件要提到的是,如果 value 包含 null 它可能会抛出异常,因此您必须检查字段是否包含 null:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM