SQL 我是否可以在按 ID 分组的 tablix 行中包含子报表?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24744728/
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
Is it possible for me to include a sub report in a tablix row that is grouped by an ID?
提问by Nick G
Is it possible for me to include a sub report in a tablix row that is grouped by an ID and pass that ID into the sub-report to be ran? Basically, the sub-report would return data from a second dataset based off of the ID that is being used in the grouping of the main tablix?
我是否可以在按 ID 分组的 tablix 行中包含子报告并将该 ID 传递到要运行的子报告中?基本上,子报告将根据主 Tablix 分组中使用的 ID 从第二个数据集中返回数据?
My main tablix has 4 rows that are grouped together by an ID where i create a few graphs from a main dataset. My second dataset returns simulations that can contain hundreds of rows per ID, which is why I don't want to do this in a join statement because it is extremely ineffecient. I want to add a tablix to row 5 within my main tablix and display the results from dataset2, but only have it run within the current group of Tablix1.
我的主要 tablix 有 4 行,它们按 ID 分组在一起,我在其中从主数据集创建了一些图形。我的第二个数据集返回每个 ID 可以包含数百行的模拟,这就是为什么我不想在 join 语句中这样做,因为它非常低效。我想在主 tablix 的第 5 行添加一个 tablix 并显示 dataset2 的结果,但只让它在当前的 Tablix1 组中运行。
Dataset1 would be similar to this with a unique iGoalID for each group in the main tablix.
数据集 1 与此类似,主 tablix 中的每个组都有一个唯一的 iGoalID。
Dataset2 would look like this;
Dataset2 看起来像这样;
I'd like to be able to loop through DataSet2 and display the data, but only grouped by the main tablix iGoalID equaling dataset2's iGoalID
我希望能够遍历 DataSet2 并显示数据,但只能按等于 dataset2 的 iGoalID 的主 tablix iGoalID 分组
回答by lethaljd
You have to build the subreport as a separate report .rdl and build it to accept a parameter of the ID. You will then pass the ID parameter to the subreport once it's added to the parent report. Once the sub is built, tested, and saved...add it to your main report using Insert-> Subreport on the main tab. You should be able to select the cell on the design view where you want the subreport to be and insert the subreport there.
您必须将子报告构建为单独的报告 .rdl 并将其构建为接受 ID 的参数。一旦将 ID 参数添加到父报表,您就会将 ID 参数传递给子报表。构建、测试和保存子报表后……使用主选项卡上的插入-> 子报表将其添加到主报表中。您应该能够在设计视图上选择子报表所在的单元格并在那里插入子报表。
To specify parameters to pass to a subreport
指定要传递给子报表的参数
- In Design view, right-click the subreport and then click Subreport
Properties.
- In the Subreport Properties dialog box, click Parameters. Click Add. A new row is added to the parameter grid.
- In the Name text box, type the name of a parameter in the subreport or choose it from the list box. This name must match a report parameter, not a query parameter, in the subreport.
- In the Value list box, type or select a value to pass to the subreport. This value can be static text or an expression that references a field or other object in the main report.
- 在设计视图中,右键单击子报表,然后单击子报表属性。
- 在“子报表属性”对话框中,单击“参数”。单击添加。新行被添加到参数网格中。
- 在名称文本框中,键入子报表中参数的名称或从列表框中选择它。此名称必须匹配子报表中的报表参数,而不是查询参数。
- 在“值”列表框中,键入或选择要传递给子报表的值。此值可以是静态文本或引用主报表中的字段或其他对象的表达式。
回答by Rajenthiran T
Step 1: Add new report and fill the data using dataset(Ex Report Name :: SubReport)
步骤 1:添加新报告并使用数据集填充数据(Ex Report Name :: SubReport)
Step 2: Create another New Report and fill the data using dataset(Ex Report Name :: Main_Report)
步骤 2:创建另一个新报告并使用数据集填充数据(Ex Report Name :: Main_Report)
Step 3: Now which row cell you want using subreport, select that cell and right click ---> go to insert --> Add the sub report in particular cell.
第 3 步:现在要使用子报表的行单元格,选择该单元格并右键单击 ---> 插入 --> 在特定单元格中添加子报表。
Step 4: Then right click on that cell and go to ---> Subreport properties and select which report(Subreport name) is using in drop-down .Don't use other properties and now see preview the main report.
第 4 步:然后右键单击该单元格并转到 ---> 子报表属性并在下拉列表中选择正在使用的报表(子报表名称)。不要使用其他属性,现在查看预览主报表。
Step 5: Now you can see full report data in assigned columns.
第 5 步:现在您可以在指定的列中看到完整的报告数据。
Step 6: But you are use parameter based on primary key that time you have to keeping mind an one think .Which parameter name passing to subreport the same name only using main report parameter. This parameter should have reference column into main and sub reports.
第 6 步:但是您使用基于主键的参数,那时您必须牢记一个想法。哪个参数名称仅使用主报告参数传递给同名的子报告。此参数应在主报告和子报告中具有参考列。
Step 7: Try this if have any doubt reply me i will clear on this.
第 7 步:如果有任何疑问,请尝试此操作,请回复我,我会对此进行澄清。