简体   繁体   English

SSRS 错误 - “报表项表达式只能引用当前数据集范围内的字段,或者如果在聚合内

[英]SSRS Error - "Report item expressions can only refer to fields within the current dataset scope or, if inside an aggregate

I'm new to SSRS and I'm not sure if it will do what I would like to do.我是 SSRS 的新手,我不确定它是否会做我想做的事情。

I'm getting the following error in SSRS:我在 SSRS 中收到以下错误:

"The Value expression for the text box 'Textbox17' refers to the field 'DayCnt'. Report item expressions can only refer to fields withing the current dataset scope or, if inside an aggregate, the specified dataset scope. Letters in the names of fields must use the correct case." “文本框‘Textbox17’的值表达式引用字段‘DayCnt’。报表项表达式只能引用当前数据集范围内的字段,或者如果在聚合内,则引用指定的数据集范围。字段名称中的字母必须使用正确的大小写。”

I have a list that's 3 rows and 3 columns.我有一个 3 行 3 列的列表。 I need to use multiple data sets across the rows and columns.我需要跨行和列使用多个数据集。 I would like everything on the report to be grouped on the school ID, which each dataset does have.我希望报告中的所有内容都根据每个数据集都有的学校 ID 进行分组。

I will be using multiple datasets per cell in some cases and I'm using a textbox and then dragging the dataset field into it.在某些情况下,我将在每个单元格中使用多个数据集,并且我正在使用一个文本框,然后将数据集字段拖入其中。 I'm not sure if grouping is the problem.我不确定分组是否是问题所在。 I'm not sure how to group the entire list at once, or if it is row based, or how the grouping works with a list with multiple columns.我不确定如何一次对整个列表进行分组,或者它是否基于行,或者分组如何与具有多列的列表一起使用。

How can I get everything in the list to be based off of the school ID?我怎样才能让列表中的所有内容都基于学校 ID?

Thank you for your help.谢谢您的帮助。

在此处输入图像描述

You can reference more than one dataset in the same data region (table, etc.) but only if it makes sense to use aggregate functions on all the datasets except the primary one that your grouping is based on.可以在同一数据区域(表等)中引用多个数据集,但前提是对除您的分组所基于的主要数据集之外的所有数据集使用聚合函数是有意义的。 I'm not sure if this makes sense for your use case or not.我不确定这对您的用例是否有意义。

An aggregate function is something like First .聚合函数类似于First If you don't specify the dataset, it defaults to the "current dataset."如果您不指定数据集,则默认为“当前数据集”。 The current dataset is an invisible default that you can't see or set anywhere in the UI, as far as I can tell.据我所知,当前数据集是一个不可见的默认值,您无法在 UI 中的任何位置看到或设置它。

=First(Fields!MyField.Value)

vs.对比

=First(Fields!MyField.Value, "MyDataset")

Now, there are a couple of tricky things to know about the Report Builder UI.现在,有一些关于 Report Builder UI 的棘手事情需要了解。

  • When you drag a field into your report, the expression it creates does not specify the dataset.当您将一个字段拖到报表中时,它创建的表达式不会指定数据集。
  • When you drag a field into your report, it changes the current dataset!当您将一个字段拖到报表中时,它会更改当前数据集!

This leads to exasperating behavior such as the following:这会导致令人恼火的行为,例如:

  1. Create a data region.创建数据区域。
  2. Set its grouping to a field from Dataset1 .将其分组设置为Dataset1中的一个字段。
  3. Drag in a field from Dataset1 .Dataset1一个字段。
  4. Run the report.运行报告。 It works!有用!
  5. Drag in a field from Dataset2 .Dataset2一个字段。 RB will automatically use an aggregate function, as you would expect.正如您所期望的,RB 将自动使用聚合函数。
  6. Run the report again.再次运行报告。 Now you get an error, not on either of your fields, but on the grouping of your data region.现在你得到一个错误,不是在你的任何一个字段上,而是在你的数据区域的分组上。

The problem is that dragging in the field from Dataset2 changed the current dataset to Dataset2 and broke everything that uses Dataset1 without explicitly specifying it.问题是从Dataset2字段将当前数据集更改为Dataset2 ,并破坏了所有使用Dataset1而未明确指定的内容。 The solution is hacky:解决方案是 hacky:

  1. Manually change the expressions of all your fields from Dataset2 so they explicitly reference the dataset, or手动更改Dataset2中所有字段的表达式,以便它们明确引用数据集,或者
  2. Reset the current dataset by dragging in a field from Dataset1 and deleting it.通过从Dataset1中拖入一个字段并将其删除来重置当前数据集。

You cannot use different datasets on only one SSRS table.您不能仅在一个 SSRS 表上使用不同的数据集。 One table should only refer to one dataset.一张表应该只引用一个数据集。

And the solution to your question is: recreate your dataset (query), try to get one dataset by using distributed query if they are on different server instance, or specify database name when they are on the same server.您的问题的解决方案是:重新创建数据集(查询),如果它们位于不同的服务器实例上,则尝试使用分布式查询获取一个数据集,或者当它们位于同一服务器上时指定数据库名称。

You might have done some modification on the Dataset and you did not refreshed the fields.您可能对数据集做了一些修改,但没有刷新字段。

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

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