是否可以在报告中包含多个参数

时间:2013-03-08 09:41:06

标签: sql tsql reporting-services

我的报告中有一个名为报告级别的参数,您可以从4个选项中进行选择:

公司 BDM 区域 站点

我希望能够做到的是:

选择BDM,这将打开另一个参数调用BDM列表(这基于从查询中获取值),但我希望其他参数保持灰色。一旦从BDM列表中进行选择,则时间和日期参数变为可用。

这可能吗?

这些是我的BDM列表和区域列表的数据集:

    SELECT SiteInfo FROM
    ((SELECT DISTINCT BDM, Region, SiteName As SiteInfo 
    FROM Site 
    WHERE @ReportingLevel = 'BDM' 
    union all
    SELECT DISTINCT BDM, Region, SiteName As SiteInfo 
    FROM Site 
    WHERE @ReportingLevel = 'Region' ) 
    union all
    SELECT DISTINCT BDM, Region, SiteName As SiteInfo 
    FROM Site
    WHERE @ReportingLevel = 'SiteName') AS QRY2

这是我的主要数据集:

    SELECT       OccupancyDetail.CalendarYear, OccupancyDetail.CalendarMonth, SUM(OccupancyDetail.No_of_Nights) AS No_of_Nights, 
                         SUM(OccupancyDetail.Capacity) AS Capacity
FROM            OccupancyDetail INNER JOIN
                         Site ON OccupancyDetail.Site_Skey = Site.Site_Skey

WHERE  (OccupancyDetail.ReferenceDate = convert(Date,getdate()))
AND CASE WHEN @Time = 'YEAR' THEN CAST(CalendarYear as varchar(4)) else CalendarMonth + ' ' + CAST(CalendarYear as varchar(4)) end in (@Dates)
AND Site.BDM IN (@BDM)
AND Site.Region IN (@Region)
AND Site.SiteName IN (@SiteName)


GROUP BY OccupancyDetail.ReferenceDate, OccupancyDetail.CalendarYear, OccupancyDetail.CalendarMonth

时间数据集

select DateChoice FROM
(select distinct CalendarYear, 1 as MonthNumber,CAST(CalendarYear as varchar(4)) as DateChoice from Time
where @Time = 'YEAR'


union all

select Distinct CalendarYear, MonthNumber,CalendarMonth + ' ' + CAST(CalendarYear as varchar(4)) as DateChoice from Time where @Time = 'MONTH') as QRYDATA
ORDER BY CalendarYear,MonthNumber

我希望你能帮助我,这是我第三天的工作。

由于

韦恩

1 个答案:

答案 0 :(得分:0)

我相信您正在寻找使用级联参数,以下是一些可以帮助您的链接。

http://technet.microsoft.com/en-us/library/dd255197.aspx

http://thevirtualzoneblog.wordpress.com/2011/03/30/creating-cascading-parameter-reports-using-sql-server-reporting-services-v2008/

使用第一个链接,转到标记为'要创建数据集以提供相关参数值的部分'。下一个显示在父选择了选项之前灰色显示的参数:

http://www.resultdata.com/adding-cascading-parameters-to-a-ssrs-report/


更新

我找到了一个视频教程: http://www.youtube.com/watch?v=VAYGupJcHkU