Microsoft 报告添加两个列值
是否可以添加两个列值,假设我有 3 列:
Item 1 | Item 2 | Total
=Fields!Item1.Value | =Fields!Item1.Value | ???
我想避免(出于可维护性原因)做这样的事情:
=Fields!Item1.Value + Fields!Item2.Value
我宁愿寻找类似
Column1Value + Column2Value
谢谢大家!!!!
Is it possible to add two column values say I have 3 columns:
Item 1 | Item 2 | Total
=Fields!Item1.Value | =Fields!Item1.Value | ???
What I want to avoid (for maintainability reasons) is doing something like this:
=Fields!Item1.Value + Fields!Item2.Value
I am rather looking for something like
Column1Value + Column2Value
Thanks Guys!!!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
听起来您想要做的是引用报表对象(文本框)的值而不是查询中的列。您可以使用 ReportItems! 来完成此操作。
当您从数据集中拖出列时,它可能会在列之后命名文本框,如果列名称可以变化,您将需要为将在其中显示该值的文本框分配一个静态值。
因此,在您给出的最初示例中,您将拥有名称为 Item1、Item2 和 Total 的文本框。因此,在相应的 Total 文本框中,您将需要:
或者如果您将文本框命名为 Red 和 Blue,则为:
当您点击“!”时,将弹出可用的 ReportItems 列表在报告项目之后。
Sounds like what you would like to do is reference the value of the report object (the textbox) rather than the column from the query. You can do this by using ReportItems!.
When you drag out the column from the dataset, it may name the text box after the column, if the column name can vary you will want to assign a static value to the text box in which the value will appear.
So, in the initial example you gave, you will have textboxes by the names of Item1, Item2, and Total. Thus, in the appropriate Total textbox you will want:
or if you named the textboxes Red and Blue it would be:
A list of available ReportItems will pop up when you hit '!' after ReportItems.
您还可以通过在数据集中添加计算字段来完成此操作。因此,添加两个源字段,通常将它们称为 Item1 和 Item2 - 将它们的 Source 设置为数据中字段的名称来源。然后添加一个计算字段,通过将字段的表达式设置为=Fields!Item1.Value + Fields!Item2.Value<,将其称为总计到报表数据集/em>。
然后,您可以在报告中的任何位置使用 =Fields!Total.Value 访问计算值。
通过这种方式,您无需修改底层数据源即可获得计算,它更易于维护(计算在一个地方),它简化了在整个报告中引用计算的过程。
You could also do this by adding a calculated field in your dataset. So add your two source fields, lets call them Item1 and Item2, normally - with their Source set to the name of the field in the data source. Then add a calculated field, letss call it Total to the report dataset by setting the Field's Expression to =Fields!Item1.Value + Fields!Item2.Value.
Then anywhere in your report you can access the calculated value by using =Fields!Total.Value.
This way you get your calculation without modifying the underlying datasource, it is more maintainable (the calculation in one place) it simplifies referencing the calculation throughout the report.
我只需在查询中进行添加并将其作为计算字段返回。
例如,
我没有看到这方面的可维护性问题。如果您需要将查询与其他所有内容分开,请考虑使用存储过程或某种工厂来生成查询。
I would just do the addition in the query and return it as a calculated field.
e.g.
I don't see the maintainability problem with this. If you need to keep the query separate from everything else, consider stored procedures or some sort of factory to generate the query.
如果您使用矩阵,则您寻求的行为是内置的。
If you use a matrix, the behavior you seek is inbuilt.