我需要帮助来修改现有的ssrs
报告。目前,最终用户只能从pFiscalMonth
参数中选择一个值来查看报告。用户现在请求修改报告以允许他们选择一个月以上来查看报告。
主报表数据集是一个非常长的查询:CTE加入其他表。我修改了这个主报告数据集where子句如下:
WITH FinanceReportSchedule AS(SELECT 52 AS[FinanceRepor ScheduleSK], 2015 AS FiscalYear, 1 AS FiscalMonth, '2014-04-30 00:00:00' AS[Mon hEndDate],
'2014-05-12 00:00:00' AS PayrollFinalDate, 12 AS PayrollFinalDayCount, '2014-05-16 00:00:00' AS RevExpPreliminaryDate,
16 AS RevExpPreliminaryDayCount, '2014-05-26 00:00:00' AS RevExpFinalDate, 26 AS RevExpFinalDayCount
UNION ALL
SELECT 53 AS Expr1, 2015 AS Expr2, 2 AS Expr3, '2014-05-31 00:00:00' AS Expr4, '2014-06-11 00:00:00' AS Expr5, 11 AS Expr6,
'2014-06-17 00:00:00' AS Expr7, 17 AS Expr8, '2014-06-24 00:00:00' AS Expr9, 24 AS Expr10
UNION ALL
SELECT 54 AS Expr1, 2015 AS Expr2, 3 AS Expr3, '2014-06-30 00:00:00' AS Expr4, '2014-07-11 00:00:00' AS Expr5, 11 AS Expr6,
'2014-07-17 00:00:00' AS Expr7, 17 AS Expr8, '2014-07-24 00:00:00' AS Expr9, 24 AS Expr10
UNION ALL
SELECT 55 AS Expr1, 2015 AS Expr2, 4 AS Expr3, '2014-07-31 00:00:00' AS Expr4, '2014-08-13 00:00:00' AS Expr5, 13 AS Expr6,
'2014-08-19 00:00:00' AS Expr7, 19 AS Expr8, '2014-08-26 00:00:00' AS Expr9, 26 AS Expr10
UNION ALL
SELECT 56 AS Expr1, 2015 AS Expr2, 5 AS Expr3, '2014-08-31 00:00:00' AS Expr4, '2014-09-11 00:00:00' AS Expr5, 11 AS Expr6,
'2014-09-17 00:00:00' AS Expr7, 17 AS Expr8, '2014-09-24 00:00:00' AS Expr9, 24 AS Expr10
UNION ALL
SELECT 57 AS Expr1, 2015 AS Expr2, 6 AS Expr3, '2014-09-30 00:00:00' AS Expr4, '2014-10-10 00:00:00' AS Expr5, 10 AS Expr6,
'2014-10-17 00:00:00' AS Expr7, 17 AS Expr8, '2014-10-24 00:00:00' AS Expr9, 24 AS Expr10
UNION ALL
SELECT 58 AS Expr1, 2015 AS Expr2, 7 AS Expr3, '2014-10-31 00:00:00' AS Expr4, '2014-11-12 00:00:00' AS Expr5, 12 AS Expr6,
'2014-11-18 00:00:00' AS Expr7, 18 AS Expr8, '2014-11-25 00:00:00' AS Expr9, 25 AS Expr10
UNION ALL
SELECT 59 AS Expr1, 2015 AS Expr2, 8 AS Expr3, '2014-11-30 00:00:00' AS Expr4, '2014-12-10 00:00:00' AS Expr5, 10 AS Expr6,
'2014-12-16 00:00:00' AS Expr7, 16 AS Expr8, '2014-12-23 00:00:00' AS Expr9, 23 AS Expr10
UNION ALL
SELECT 60 AS Expr1, 2015 AS Expr2, 9 AS Expr3, '2014-12-31 00:00:00' AS Expr4, '2015-01-13 00:00:00' AS Expr5, 13 AS Expr6,
'2015-01-19 00:00:00' AS Expr7, 19 AS Expr8, '2015-01-26 00:00:00' AS Expr9, 26 AS Expr10
UNION ALL
SELECT 61 AS Expr1, 2015 AS Expr2, 10 AS Expr3, '2015-01-31 00:00:00' AS Expr4, '2015-02-11 00:00:00' AS Expr5, 11 AS Expr6,
'2015-02-18 00:00:00' AS Expr7, 18 AS Expr8, '2015-02-25 00:00:00' AS Expr9, 25 AS Expr10
UNION ALL
SELECT 62 AS Expr1, 2015 AS Expr2, 11 AS Expr3, '2015-02-28 00:00:00' AS Expr4, '2015-03-10 00:00:00' AS Expr5, 10 AS Expr6,
'2015-03-16 00:00:00' AS Expr7, 16 AS Expr8, '2015-03-23 00:00:00' AS Expr9, 23 AS Expr10
UNION ALL
SELECT 63 AS Expr1, 2015 AS Expr2, 12 AS Expr3, '2015-03-31 00:00:00' AS Expr4, '2015-04-09 00:00:00' AS Expr5, 9 AS Expr6,
'2015-04-15 00:00:00' AS Expr7, 15 AS Expr8, '2015-05-15 00:00:00' AS Expr9, 45 AS Expr10
UNION ALL
SELECT 64 AS Expr1, 2016 AS Expr2, 1 AS Expr3, '2015-04-30 00:00:00' AS Expr4, '2015-05-11 00:00:00' AS Expr5, 11 AS Expr6,
'2015-05-18 00:00:00' AS Expr7, 18 AS Expr8, '2015-05-25 00:00:00' AS Expr9, 25 AS Expr10
UNION ALL
SELECT 65 AS Expr1, 2016 AS Expr2, 2 AS Expr3, '2015-05-31 00:00:00' AS Expr4, '2015-06-09 00:00:00' AS Expr5, 9 AS Expr6,
'2015-06-15 00:00:00' AS Expr7, 15 AS Expr8, '2015-06-22 00:00:00' AS Expr9, 22 AS Expr10
UNION ALL
SELECT 66 AS Expr1, 2016 AS Expr2, 3 AS Expr3, '2015-06-30 00:00:00' AS Expr4, '2015-07-10 00:00:00' AS Expr5, 10 AS Expr6,
'2015-07-16 00:00:00' AS Expr7, 16 AS Expr8, '2015-07-23 00:00:00' AS Expr9, 23 AS Expr10
UNION ALL
SELECT 67 AS Expr1, 2016 AS Expr2, 4 AS Expr3, '2015-07-31 00:00:00' AS Expr4, '2015-08-12 00:00:00' AS Expr5, 12 AS Expr6,
'2015-08-18 00:00:00' AS Expr7, 18 AS Expr8, '2015-08-25 00:00:00' AS Expr9, 25 AS Expr10
UNION ALL
SELECT 68 AS Expr1, 2016 AS Expr2, 5 AS Expr3, '2015-08-31 00:00:00' AS Expr4, '2015-09-10 00:00:00' AS Expr5, 10 AS Expr6,
'2015-09-16 00:00:00' AS Expr7, 16 AS Expr8, '2015-09-23 00:00:00' AS Expr9, 23 AS Expr10
UNION ALL
SELECT 69 AS Expr1, 2016 AS Expr2, 6 AS Expr3, '2015-09-30 00:00:00' AS Expr4, '2015-10-12 00:00:00' AS Expr5, 12 AS Expr6,
'2015-10-16 00:00:00' AS Expr7, 16 AS Expr8, '2015-10-23 00:00:00' AS Expr9, 23 AS Expr10
UNION ALL
SELECT 70 AS Expr1, 2016 AS Expr2, 7 AS Expr3, '2015-10-31 00:00:00' AS Expr4, '2015-11-10 00:00:00' AS Expr5, 10 AS Expr6,
'2015-11-16 00:00:00' AS Expr7, 16 AS Expr8, '2015-11-23 00:00:00' AS Expr9, 23 AS Expr10
UNION ALL
SELECT 71 AS Expr1, 2016 AS Expr2, 8 AS Expr3, '2015-11-30 00:00:00' AS Expr4, '2015-12-09 00:00:00' AS Expr5, 9 AS Expr6,
'2015-12-15 00:00:00' AS Expr7, 15 AS Expr8, '2015-12-22 00:00:00' AS Expr9, 22 AS Expr10
UNION ALL
SELECT 72 AS Expr1, 2016 AS Expr2, 9 AS Expr3, '2015-12-31 00:00:00' AS Expr4, '2016-01-13 00:00:00' AS Expr5, 13 AS Expr6,
'2016-01-19 00:00:00' AS Expr7, 19 AS Expr8, '2016-01-26 00:00:00' AS Expr9, 26 AS Expr10
UNION ALL
SELECT 73 AS Expr1, 2016 AS Expr2, 10 AS Expr3, '2016-01-31 00:00:00' AS Expr4, '2016-02-09 00:00:00' AS Expr5, 9 AS Expr6,
'2016-02-15 00:00:00' AS Expr7, 15 AS Expr8, '2016-02-22 00:00:00' AS Expr9, 22 AS Expr10
UNION ALL
SELECT 74 AS Expr1, 2016 AS Expr2, 11 AS Expr3, '2016-02-29 00:00:00' AS Expr4, '2016-03-09 00:00:00' AS Expr5, 9 AS Expr6,
'2016-03-15 00:00:00' AS Expr7, 15 AS Expr8, '2016-03-22 00:00:00' AS Expr9, 22 AS Expr10
UNION ALL
SELECT 75 AS Expr1, 2016 AS Expr2, 12 AS Expr3, '2016-03-31 00:00:00' AS Expr4, '2016-04-13 00:00:00' AS Expr5, 13 AS Expr6,
'2016-04-15 00:00:00' AS Expr7, 15 AS Expr8, '2016-05-17 00:00:00' AS Expr9, 47 AS Expr10
UNION ALL
SELECT 76 AS Expr1, 2017 AS Expr2, 1 AS Expr3, '2016-04-30 00:00:00' AS Expr4, '2016-05-12 00:00:00' AS Expr5, 12 AS Expr6,
'2016-05-16 00:00:00' AS Expr7, 16 AS Expr8, '2016-05-26 00:00:00' AS Expr9, 26 AS Expr10
UNION ALL
SELECT 77 AS Expr1, 2017 AS Expr2, 2 AS Expr3, '2016-05-31 00:00:00' AS Expr4, '2016-06-11 00:00:00' AS Expr5, 11 AS Expr6,
'2016-06-17 00:00:00' AS Expr7, 17 AS Expr8, '2016-06-24 00:00:00' AS Expr9, 24 AS Expr10
UNION ALL
SELECT 78 AS Expr1, 2017 AS Expr2, 3 AS Expr3, '2016-06-30 00:00:00' AS Expr4, '2016-07-11 00:00:00' AS Expr5, 11 AS Expr6,
'2016-07-17 00:00:00' AS Expr7, 17 AS Expr8, '2016-07-24 00:00:00' AS Expr9, 24 AS Expr10
UNION ALL
SELECT 79 AS Expr1, 2017 AS Expr2, 4 AS Expr3, '2016-07-31 00:00:00' AS Expr4, '2016-08-13 00:00:00' AS Expr5, 13 AS Expr6,
'2016-08-19 00:00:00' AS Expr7, 19 AS Expr8, '2016-08-26 00:00:00' AS Expr9, 26 AS Expr10
UNION ALL
SELECT 80 AS Expr1, 2017 AS Expr2, 5 AS Expr3, '2016-08-31 00:00:00' AS Expr4, '2016-09-11 00:00:00' AS Expr5, 11 AS Expr6,
'2016-09-17 00:00:00' AS Expr7, 17 AS Expr8, '2016-09-24 00:00:00' AS Expr9, 24 AS Expr10
UNION ALL
SELECT 81 AS Expr1, 2017 AS Expr2, 6 AS Expr3, '2016-09-30 00:00:00' AS Expr4, '2016-10-10 00:00:00' AS Expr5, 10 AS Expr6,
'2016-10-17 00:00:00' AS Expr7, 17 AS Expr8, '2016-10-24 00:00:00' AS Expr9, 24 AS Expr10
UNION ALL
SELECT 82 AS Expr1, 2017 AS Expr2, 7 AS Expr3, '2016-10-31 00:00:00' AS Expr4, '2016-11-12 00:00:00' AS Expr5, 12 AS Expr6,
'2016-11-18 00:00:00' AS Expr7, 18 AS Expr8, '2016-11-25 00:00:00' AS Expr9, 25 AS Expr10
UNION ALL
SELECT 83 AS Expr1, 2017 AS Expr2, 8 AS Expr3, '2016-11-30 00:00:00' AS Expr4, '2016-12-10 00:00:00' AS Expr5, 10 AS Expr6,
'2016-12-16 00:00:00' AS Expr7, 16 AS Expr8, '2016-12-23 00:00:00' AS Expr9, 23 AS Expr10
UNION ALL
SELECT 84 AS Expr1, 2017 AS Expr2, 9 AS Expr3, '2016-12-31 00:00:00' AS Expr4, '2017-01-13 00:00:00' AS Expr5, 13 AS Expr6,
'2017-01-19 00:00:00' AS Expr7, 19 AS Expr8, '2017-01-26 00:00:00' AS Expr9, 26 AS Expr10
UNION ALL
SELECT 85 AS Expr1, 2017 AS Expr2, 10 AS Expr3, '2017-01-31 00:00:00' AS Expr4, '2017-02-11 00:00:00' AS Expr5, 11 AS Expr6,
'2017-02-18 00:00:00' AS Expr7, 18 AS Expr8, '2017-02-25 00:00:00' AS Expr9, 25 AS Expr10
UNION ALL
SELECT 86 AS Expr1, 2017 AS Expr2, 11 AS Expr3, '2017-02-28 00:00:00' AS Expr4, '2017-03-10 00:00:00' AS Expr5, 10 AS Expr6,
'2017-03-16 00:00:00' AS Expr7, 16 AS Expr8, '2017-03-23 00:00:00' AS Expr9, 23 AS Expr10
UNION ALL
SELECT 87 AS Expr1, 2017 AS Expr2, 12 AS Expr3, '2017-03-31 00:00:00' AS Expr4, '2017-04-09 00:00:00' AS Expr5, 9 AS Expr6,
'2017-04-15 00:00:00' AS Expr7, 15 AS Expr8, '2017-05-15 00:00:00' AS Expr9, 15 AS Expr10
UNION ALL
SELECT 88 AS Expr1, 2018 AS Expr2, 1 AS Expr3, '2017-04-30 00:00:00' AS Expr4, '2017-05-11 00:00:00' AS Expr5, 11 AS Expr6,
'2017-05-18 00:00:00' AS Expr7, 18 AS Expr8, '2017-05-25 00:00:00' AS Expr9, 25 AS Expr10
UNION ALL
SELECT 89 AS Expr1, 2018 AS Expr2, 2 AS Expr3, '2017-05-31 00:00:00' AS Expr4, '2017-06-09 00:00:00' AS Expr5, 9 AS Expr6,
'2017-06-15 00:00:00' AS Expr7, 15 AS Expr8, '2017-06-22 00:00:00' AS Expr9, 22 AS Expr10
UNION ALL
SELECT 90 AS Expr1, 2018 AS Expr2, 3 AS Expr3, '2017-06-30 00:00:00' AS Expr4, '2017-07-10 00:00:00' AS Expr5, 10 AS Expr6,
'2017-07-16 00:00:00' AS Expr7, 16 AS Expr8, '2017-07-23 00:00:00' AS Expr9, 23 AS Expr10
UNION ALL
SELECT 91 AS Expr1, 2018 AS Expr2, 4 AS Expr3, '2017-07-31 00:00:00' AS Expr4, '2017-08-12 00:00:00' AS Expr5, 12 AS Expr6,
'2017-08-18 00:00:00' AS Expr7, 18 AS Expr8, '2017-08-25 00:00:00' AS Expr9, 25 AS Expr10
UNION ALL
SELECT 92 AS Expr1, 2018 AS Expr2, 5 AS Expr3, '2017-08-31 00:00:00' AS Expr4, '2017-09-10 00:00:00' AS Expr5, 10 AS Expr6,
'2017-09-16 00:00:00' AS Expr7, 16 AS Expr8, '2017-09-23 00:00:00' AS Expr9, 23 AS Expr10
UNION ALL
SELECT 93 AS Expr1, 2018 AS Expr2, 6 AS Expr3, '2017-09-30 00:00:00' AS Expr4, '2017-10-12 00:00:00' AS Expr5, 12 AS Expr6,
'2017-10-16 00:00:00' AS Expr7, 16 AS Expr8, '2017-10-23 00:00:00' AS Expr9, 23 AS Expr10
UNION ALL
SELECT 94 AS Expr1, 2018 AS Expr2, 7 AS Expr3, '2017-10-31 00:00:00' AS Expr4, '2017-11-10 00:00:00' AS Expr5, 10 AS Expr6,
'2017-11-16 00:00:00' AS Expr7, 16 AS Expr8, '2017-11-23 00:00:00' AS Expr9, 23 AS Expr10
UNION ALL
SELECT 95 AS Expr1, 2018 AS Expr2, 8 AS Expr3, '2017-11-30 00:00:00' AS Expr4, '2017-12-09 00:00:00' AS Expr5, 9 AS Expr6,
'2017-12-15 00:00:00' AS Expr7, 15 AS Expr8, '2017-12-22 00:00:00' AS Expr9, 22 AS Expr10
UNION ALL
SELECT 96 AS Expr1, 2018 AS Expr2, 9 AS Expr3, '2017-12-31 00:00:00' AS Expr4, '2018-01-13 00:00:00' AS Expr5, 13 AS Expr6,
'2018-01-19 00:00:00' AS Expr7, 19 AS Expr8, '2018-01-26 00:00:00' AS Expr9, 26 AS Expr10
UNION ALL
SELECT 97 AS Expr1, 2018 AS Expr2, 10 AS Expr3, '2018-01-31 00:00:00' AS Expr4, '2018-02-09 00:00:00' AS Expr5, 9 AS Expr6,
'2018-02-15 00:00:00' AS Expr7, 15 AS Expr8, '2018-02-22 00:00:00' AS Expr9, 22 AS Expr10
UNION ALL
SELECT 98 AS Expr1, 2018 AS Expr2, 11 AS Expr3, '2018-02-28 00:00:00' AS Expr4, '2018-03-09 00:00:00' AS Expr5, 9 AS Expr6,
'2018-03-15 00:00:00' AS Expr7, 15 AS Expr8, '2018-03-22 00:00:00' AS Expr9, 22 AS Expr10
UNION ALL
SELECT 99 AS Expr1, 2018 AS Expr2, 12 AS Expr3, '2018-03-31 00:00:00' AS Expr4, '2018-04-13 00:00:00' AS Expr5, 13 AS Expr6,
'2018-04-15 00:00:00' AS Expr7, 15 AS Expr8, '2018-05-17 00:00:00' AS Expr9, 17 AS Expr10)
SELECT aa.Union_code, aa.WorkedHrs, aa.Pay_Class, aa.PType, aa.Amount, aa.FiscalYear, aa.FiscalPeriod, aa.FiscalYearReportName, aa.Employee, bb.LastName, bb.FirstName,
cc.PayClassDesc, ff.AU, ff.Owner, ff.FirstName AS AUOwnerFirstName, ff.LastName AS AUOwnerLastName, ff.Program, ee.PersonResponsible, dd.Level9Code,
dd.Level9Name, bb.POSITION, Dim_Pay_Position.DESCRIPTION, CASE WHEN getdate() >= PayrollFinalDate THEN 'Final' ELSE 'No Available' END AS ReportStatus
FROM(SELECT Union_code, WorkedHrs, Pay_Class, PType, Amount, FiscalYear, FiscalPeriod, FiscalYearReportName, Employee, EmployeeSK, CostCenterSK, CDateSK
FROM Fact_Pay_AUreport AS a
WHERE (AUcode = @pCostCentre) AND(FiscalYear = @pFiscalYear) AND**(FiscalPeriod IN(@pFiscalMonth))** AS aa INNER JOIN
FinanceReportSchedule AS SC ON SC.FiscalYear = aa.FiscalYear AND SC.FiscalMonth = aa.FiscalPeriod AND GETDATE() >= SC.PayrollFinalDate INNER JOIN
Dim_PayReport_Employee AS bb ON aa.EmployeeSK = bb.EmployeeSK INNER JOIN
Dim_Pay_PayClass AS cc ON aa.Pay_Class = cc.PayClassCode INNER JOIN
HierarchyCostCentre AS dd ON aa.CostCenterSK = dd.CostCentreSK INNER JOIN
DimCostCentre AS ee ON aa.CostCenterSK = ee.CostCentreSK INNER JOIN
DimSigningAuthority AS ff ON ee.Code = ff.AU INNER JOIN
Dim_Pay_Position ON bb.POSITION = Dim_Pay_Position.POSITION
however when i tried to execute modified query in query designer got error message said IN clause is not compatible with the query.
Here is the data set query for this @pFiscalMonth parameter:
SELECT DISTINCT Fact_Pay_AUreport.FiscalPeriod, DimDate.MonthName, Fact_Pay_AUreport.FiscalYear
FROM Fact_Pay_AUreport INNER JOIN
DimDate ON Fact_Pay_AUreport.CDateSK = DimDate.DateSK
WHERE (Fact_Pay_AUreport.FiscalYear = 2014)
ORDER BY Fact_Pay_AUreport.FiscalPeriod
顺便说一句,我已经设置了参数属性:可用值:从查询中获取值;标签名称:MonthName; value:MonthName
有人可以告诉我如何修复此错误吗?我应该使用拆分功能吗?我查了数据库,没有可用的分割功能。如果有必要,可能需要创建一个。
答案 0 :(得分:0)
cs:ip
之后,我认为你需要另一个)。在(FiscalPeriod IN (@pFiscalMonth))
之后FROM(
之后,括号内没有关闭。