简体   繁体   English

在SSRS 2008报告中将字段添加到表达式中

[英]Adding Fields into an expression in an SSRS 2008 report

Thank you in advance for taking your time to answer my question. 预先感谢您抽出宝贵时间回答我的问题。

I am having trouble with expressions in the SSRS reporting system. 我在SSRS报告系统中遇到表达式问题。 The Field I am adding required fields from the dataset I provided in the report, however when I try to preview the report I get the Following message: 字段我正在从报表中提供的数据集中添加必填字段,但是当我尝试预览报表时,出现以下消息:

"A Value expression used for the report parameter 'Policies_Total' refers to a field. Fields cannot be used in report parameter expressions." “用于报表参数'Policies_Total'的值表达式引用一个字段。该字段不能在报表参数表达式中使用。”

This is my expression: 这是我的表情:

=IIF(Sum(Fields!policy_id.Value, "DataSet1") Is Null, 0, Count(Sum(Fields!policy_id.Value, "DataSet1")))

That was suppoed to be converted from Crystal reports which has the following expression: 假定可以从具有以下表达式的Crystal报表中进行转换:

If IsNull ({usp_rep_agent_cases;1.policy_id}) then
    0
Else
    Count ({usp_rep_agent_cases;1.policy_id}) 

Any help is much appreciated. 任何帮助深表感谢。

Thank you 谢谢

I think it may be as simple as understand that a 'parameter' should be passed into SSRS before fields are created for the most part. 我认为可能很简单,那就是在大部分字段创建之前将“参数”传递给SSRS。 If this parameter is DEPENDENT on the value of something else first being chosen you cannot list it first as the field is not yet populated to my knowledge. 如果此参数取决于其他参数的值,那么您将无法首先列出该参数,因为据我所知该字段尚未填充。 It appears you are trying to use an expression to count something from a field from a dataset when you just make a dataset and reference that field directly. 看起来当您只是创建数据集并直接引用该字段时,您正试图使用​​表达式来对数据集中的某个字段进行计数。 So instead of trying an expression you may choose a few other options instead: 因此,您可以选择其他几个选项来代替尝试表达式:

  1. Choose on the left pane of your parameter 'Available Values' selected 'Get values from a query'. 在参数“可用值”的左窗格中选择“从查询中获取值”。 You may use your query which is a 'dataset', value is self explanatory, label is what the end user will see display. 您可以使用作为“数据集”的查询,其值不言自明,标签是最终用户将看到的内容。

  2. The option 'Allow null' value will accept a null value 选项“允许为空”值将接受一个空值

You may run into situations where multiple datasets may need to be used, multiple selects or querying objects. 您可能会遇到可能需要使用多个数据集,多个选择或查询对象的情况。 In my experience with SSRS it gets mad at times when you try to reference a dataset used to display data with a dataset used to determine an event or action. 以我对SSRS的经验,当您尝试引用用于显示数据的数据集与用于确定事件或动作的数据集时,有时会感到恼火。 SSRS also gets relativity slower the more Expressions you do so doing a whole report with nothing but expressions versus taking the power of the built ins of the RDL language is not really worth it IMHO. 您做的表达式越多,SSRS的相对相对性就越慢,因此,只用表达式而不是利用RDL语言的内置功能来完成整个报表就不值得恕我直言了。

For SSRS expressions you need to use IsNothing for NULL checking, something like: 对于SSRS表达式,您需要使用IsNothing进行NULL检查,例如:

=IIF(
  IsNothing(Sum(Fields!policy_id.Value, "DataSet1"))
  , 0
  , Count(Sum(Fields!policy_id.Value, "DataSet1"))
)

In fact the whole expression seems a bit odd; 实际上,整个表达式似乎有些奇怪。 what are you specifically trying to achieve with your expression? 您具体想通过表情实现什么? Are you just trying to count non-null values? 您是否只是想计算非空值?

=Sum(IIf(IsNothing(Fields!policy_id.Value), 1, 0), "DataSet1")

Also, your error seems to be saying that a parameter is referencing a field when this isn't allowed, which may not be solved by changing syntax; 另外,您的错误似乎是在不允许使用参数引用字段时,可能无法通过更改语法来解决。 I think more information about what you're trying to achieve is required here. 我认为这里需要有关您要实现的目标的更多信息。

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

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