模拟在SSRS中双击数据透视表以显示详细信息

huangapple go评论82阅读模式
英文:

Emulate pivot table double click to show detail in SSRS

问题

我有一个Excel报告,基本上是一个SQL查询,用于获取数据表,然后还有另一页显示数据的透视表以进行汇总。当我双击透视表中的单元格时,会出现一个新的工作表,仅显示该透视表行/列的数据。

在SSRS中是否有一种方法来模拟这个?我知道可以使用矩阵来模拟透视表,但我想模拟双击以显示详细信息。

我在考虑最好的方法是在SSRS中为数据创建一个单独的参数,为矩阵创建另一个参数,但似乎有点繁琐。

英文:

I have an excel report that basically is a SQL query to get a table of data, then there is another page that shows a pivot table to summarize the data. When I double click a cell in the pivot table, I get a new sheet that shows the data for that row/column of the pivot table only.

Is there a way to emulate this in SSRS? I know you can emulate pivot table with matrix but I want to emulate the double click to show detail.

I was thinking best thing would be make a separate parameter for the data and another for the matrix in SSRS but seems cumbersome.

答案1

得分: 1

你可以使用“转到报表”操作一键完成此操作。虽然不是世界上最优雅的方法,但它能够实现。

假设你有一个简单的表格,CustomerSales 按日期排序:

CustomerID 年份 日期 金额
1 2019 2019-01-01 10
1 2019 2019-02-28 11
1 2019 2019-03-15 12
1 2020 2020-01-20 13
1 2020 2020-06-30 14
1 2020 2020-07-31 15
2 2019 2019-01-01 20
2 2019 2019-02-28 21
2 2019 2019-03-15 22
2 2020 2020-01-20 23
2 2020 2020-06-30 24
2 2020 2020-07-31 25

现在我们想在SSRS中按年份将其汇总到一个矩阵中,我们创建一个按年份分组的列组,最终得到的报表如下:

客户ID 2019 2020
1 33 42
2 63 72

现在,如果我们创建一个新的报表,接受 CustomerIDYear 作为参数。

报表可以是同一个销售表格上的简单表格,数据集查询可能如下所示。

SELECT * FROM CustomerSales WHERE CustomerID = @CustomerID and [Year] = @Year

在主报表中,在矩阵中的数据文本框上设置一个“转到报表”的操作,将报表设置为你上面创建的详细报表的名称,而CustomerID和Year的参数将简单地使用主数据集中的字段,这些字段应该在下拉列表中可见。

现在,当你点击一个数字时,它将打开新的报表,显示组成矩阵单元格数据的数据。

所以,在上面的例子中,如果你点击 72,它会自动传递 2 作为CustomerID和 2020 作为年份。当展示钻取报表时,它将显示3条匹配记录。

只需确保在工具栏中使用“返回到父级”按钮,而不是浏览器的后退按钮,否则你将不得不重新运行主报表。

英文:

You can do this with a single click using a "go to report" action. It's not the most elegant thing in the world but it will work.

Let's say you have a simple table, CustomerSales by date

CustomerID Year Date Amount
1 2019 2019-01-01 10
1 2019 2019-02-28 11
1 2019 2019-03-15 12
1 2020 2020-01-20 13
1 2020 2020-06-30 14
1 2020 2020-07-31 15
2 2019 2019-01-01 20
2 2019 2019-02-28 21
2 2019 2019-03-15 22
2 2020 2020-01-20 23
2 2020 2020-06-30 24
2 2020 2020-07-31 25

Now we want to aggregate this in a matrix in SSRS by year so we create a column group that groups by Year and end up with a report that looks like this.

CustomerID 2019 2020
1 33 42
2 63 72

Now if we create a new report that accepts a CustomerID and a Year as parameters.

The report can be a simple table over the same sales table and the dataset query would look something like.

SELECT * FROM CustomerSales WHERE CustomerID = @CustomerID and [Year] = @Year

Back in your main report, in the matrix, we can set an action on the data textbox to "Go to Report", set the report to be the name of the details report you created above and the parameters for CustomerID and Year will simply be the fields from the main dataset which should be visible from the drop down list.

Now when you click on a number, it will open the new report showing the data that makes up the data in the matrix cell.

So, in the example above, if you clicked 72, it would automatically pass 2 as the CustomerID and 2020 as the year. When the drill down report appears it will how the 3 matching records.

Just be sure to use the "Back to Parent" button in the toolbar, not the browser's back button or you'll have to run the main report again.

huangapple
  • 本文由 发表于 2023年5月11日 05:25:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/76222649.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定