SSRS在FileName中使用报表参数进行数据驱动的订阅

时间:2015-09-14 20:18:01

标签: reporting-services ssrs-2008-r2

我在数据驱动订阅中使用此查询来运行大量报告。此查询有效,并为报告提供相应的文件名。我的问题是我在文件名中硬编码会计年度和会计期间。此订阅运行的实际报告具有会计年度(FY)和会计期间(AP)的参数。有没有办法在此查询中使用这些参数值作为文件名而不是硬编码>?谢谢你的帮助......

    select 
s.operating_unit
,s.region_cd

,case when extract (year from current_date)  > 8 then 
    extract (year from current_date)  +1
    else
    extract (year from current_date)  
    end as TempYear

,case when extract (month from current_date)  >8 then 
    extract (month from current_date)  - 8
    else
    extract (month from current_date) + 4 
    end as TempDay

,trim(TempYear (FORMAT '9(4)')) as vFY
,trim(TempDay (FORMAT '9(2)')) as vAP

, 'FA Additions – '|| trim(s.operating_unit) || ' - ' || s.region_cd || ‘ –‘ || vFY || ’-‘ || vAP as FileName
, 'http://reportweb/admin/rfs/Report Library/Fixed Asset Backup/FA Additions'  as FilePath


from psfs.ps_asset p
inner join rfs.stn_ops_hierarchies s on s.operating_unit = p.business_unit
where p.business_unit between 'A0460 ' and 'A0466'

group by s.operating_unit, s.region_cd
order by s.operating_unit, s.region_cd

1 个答案:

答案 0 :(得分:1)

您需要使用类似的表来查询,以便在数据驱动的订阅查询中获取年份和会计期间。

假设查询中的表确实包含必要的字段:

SELECT
s.operating_unit
,s.region_cd
, 'FA Additions – '|| trim(s.operating_unit) || ' - ' || s.region_cd || ' -  ' + YEAR(DateField) + '-' + PeriodField as FileName
, 'http://reportweb/admin/rfs/Report Library/Fixed Asset Backup/FA Additions'  as FilePath 
FROM psfs.ps_asset p
INNER JOIN rfs.stn_ops_hierarchies s on s.operating_unit = p.business_unit
WHERE p.business_unit between 'A0400' and 'A0899'

group by s.operating_unit, s.region_cd
order by s.operating_unit, s.region_cd

您可能需要使用与默认值相同的逻辑将参数添加到数据驱动查询中,这样您才能获得所需的年份/期间。