我正在尝试生成每周SSRS报告,以显示与前一时期相比的 WTD , MTD 和 YTD 值。
我已使用以下查询成功构建了报告:
WITH CTE
AS (
SELECT *,
ReportPeriod = 'Current WTD',
ColumnOrder = 1
FROM SALES_FLASH_DAILY
WHERE CompletedDate BETWEEN @CurrentWeekStart AND @Today
UNION ALL
SELECT *,
ReportPeriod = 'Prior WTD',
ColumnOrder = 2
FROM SALES_FLASH_DAILY
WHERE CompletedDate BETWEEN @PrevWeekStart AND @DayinPrevWeek
UNION ALL
SELECT *,
ReportPeriod = 'Current MTD',
ColumnOrder = 3
FROM SALES_FLASH_DAILY
WHERE CompletedDate BETWEEN @CurrentMonthStart AND @Today
UNION ALL
SELECT *,
ReportPeriod = 'Prior MTD',
ColumnOrder = 4
FROM SALES_FLASH_DAILY
WHERE CompletedDate BETWEEN @PrevMonthStart AND @DayinPrevMonth
UNION ALL
SELECT *,
ReportPeriod = 'Current YTD',
ColumnOrder = 5
FROM SALES_FLASH_DAILY
WHERE CompletedDate BETWEEN @CurrentYearStart AND @Today
UNION ALL
SELECT *,
ReportPeriod = 'Prior YTD',
ColumnOrder = 6
FROM SALES_FLASH_DAILY
WHERE CompletedDate BETWEEN @PrevYearStart AND @DayinPrevYear)
SELECT * FROM CTE;
但是,我现在想要添加列来捕获Matrix末尾每个句点的方差。
这是我正在使用的数据集的示例:
这是报告结构(报告的一部分):
这是我想要创建的输出:
有谁知道如何做到这一点?它可以在SSRS中动态完成,还是需要执行自联接以将ReportPeriodSales作为列?
谢谢。