SSRS报告 - 复杂布局?

时间:2014-05-14 07:51:13

标签: sql reporting-services ssrs-2008

我需要创建一个报告,但我不确定如何使布局正确。

报告的展示方式是Here

数据目前的格式如下:

Customer No | Sale Price | Cost Price | Margin | Date
Customer A  |   200      |    100     |  100   |  1/1/14

是否可以使用此布局设计报告?我怀疑是这样,但我还没有遇到过这个问题。

任何暗示和提示让我继续前进?

谢谢!

2 个答案:

答案 0 :(得分:3)

由于您想要的实际上是一个交叉表,如果您的数据集结构如下,则会更容易:

Customer No   Price Type   Date     Amount
-----------   ----------   -------  ------
Customer A    Sale         1/1/14   200
Customer A    Cost         1/1/14   100
Customer A    Margin       1/1/14   100
...

要实现此目的,只需在数据集的SQL语句中使用UNION ALL,如下所示:

SELECT [Customer No], 'Sale' AS [Price Type], [Date], [Sale Price]
FROM MyTable
UNION ALL
SELECT [Customer No], 'Cost' AS [Price Type], [Date], [Cost Price]
FROM MyTable
UNION ALL
SELECT [Customer No], 'Margin' AS [Price Type], [Date], [Margin]
FROM MyTable

使用这样的数据集,可以直接获得所需的报表布局,例如使用Tablix向导。

答案 1 :(得分:0)

我设法让它发挥作用。令我惊讶的是,它实际上并不太难。这可能不是最好的做事方式,但对我来说效果很好!

<强>查询

SELECT sa.[Document No_]
    ,[sa.Customer No_]
    ,DATEPART(m, sa.[Posting Date]) AS MonthName
    ,sa.Quantity
    ,sa.[Amount (LCY)]
    ,sa.[Cost (LCY)]
    ,sa.[Profit  (LCY)]
    ,c.[Salesperson Code]
    ,c.NAME
FROM [Sales Analysis] AS sa
INNER JOIN [Customer] AS c ON c.[No_] = sa.[customer no_]
WHERE [Posting Date] BETWEEN '2014-01-01'   AND '2014-05-31'
    AND [Customer No_] IS NOT NULL
    AND [Customer No_] <> ''

矩阵布局 http://i.imgur.com/vSDYBzC.jpg

<强>结果 enter image description here 谢谢你的帮助!