SQL 在 SSRS 中的一张图表中使用 2 个数据集
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24310179/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Use 2 data sets in one chart in SSRS
提问by user3691566
Is it possible to have 2 data sets and display the data for them in one chart on an SSRS report or will I need to combine the data sets?
是否可以有 2 个数据集并在 SSRS 报告的一个图表中显示它们的数据,或者我是否需要合并这些数据集?
I have number of calls answered in one dataset and number of calls missed in another and want to show them both in a graph. The data is held in different areas which is why I didn't create it in one data set to start with.
我在一个数据集中接听了电话数量,在另一个数据集中未接电话数量,并希望将它们都显示在图表中。数据保存在不同的区域,这就是为什么我一开始没有在一个数据集中创建它。
采纳答案by kyzen
This may not work for all types of charts, and does require your datasets to be constructed with common axis values:
这可能不适用于所有类型的图表,并且确实需要使用公共轴值构建数据集:
Select the chart so that the "chart data" panel appears.
Click the green "+" above the "Values" pane. You'll see a list of fields in the dataset bound to the charts data region. Rather than choosing any of those, choose "Expression" on the very bottom.
Add a value from your other dataset - note that it will probablyneed to be wrapped in an aggregate function, like SUM or FIRST. For example:
=sum(Fields!YourField.Value, "2ndDatasetName")
All datasets will need to have common axis values, otherwise you're in for a bad time. If you need to split them up, you can have TWO sets of axis values for each orientation (vertical, horizontal); to change which axis position is used, bring up the "Series Properties", choose the 2nd tab on the left ("Axes and Chart Area"), and choose the Primary or Secondary axis accordingly.
选择图表,以便出现“图表数据”面板。
单击“值”窗格上方的绿色“+”。您将看到绑定到图表数据区域的数据集中的字段列表。与其选择其中任何一个,不如选择最底部的“表达”。
从您的其他数据集中添加一个值 - 请注意,它可能需要包含在聚合函数中,例如 SUM 或 FIRST。例如:
=sum(Fields!YourField.Value, "2ndDatasetName")
所有数据集都需要具有共同的轴值,否则您将陷入困境。如果需要拆分它们,可以为每个方向(垂直、水平)设置两组轴值;要更改使用的轴位置,请调出“系列属性”,选择左侧的第二个选项卡(“轴和图表区域”),然后相应地选择主轴或辅助轴。
回答by Mariusz
You can use Lookup function to join two data-sets on common field (i.e. DateTime) and then drive part of the chart from first data-set and part from the other. It's like INNER JOIN in T-SQL. I tested it in my project and it works.
您可以使用 Lookup 功能将公共字段(即日期时间)上的两个数据集连接起来,然后从第一个数据集驱动部分图表,从另一个驱动部分图表。这就像 T-SQL 中的 INNER JOIN。我在我的项目中测试了它并且它有效。
Source: http://www.techbrothersit.com/2016/01/how-to-display-data-on-single-tablix.html
资料来源:http: //www.techbrothersit.com/2016/01/how-to-display-data-on-single-tablix.html