我有一个SSRS 2012报告,其中包含一个Tablix中的子报告。我这样做是为了为在主报表的多值@CustomerID参数中选择的每个客户提供子报表的副本。
我有一个称为“客户”的数据集,该数据集链接到tablix。从中,tablix将名为CustomerID的字段传递到子报表的@CustomerID参数(在子报表中,@ CustomerID参数不是多值)。
然后,我需要将其他三个多值参数(@ Assignedto,@ OperationalArea和@SiteClass)传递给子报表。我通过在子报表属性上使用参数匹配来传递这些参数(例如,子报表中的Assignedto与主报表中的Parameters!Assignedto.Value匹配)。
我的问题是,如果我选择了客户1和2,并且三个参数只选择了两个客户都存在的项目,则子报表运行良好。但是,如果我在仅对客户1存在的参数中选择了一个项目,则子报表将不会为客户2运行(即使也为客户2选择了有效的项目)。对于传递给子报表的所有三个多值参数,都将发生此问题。
例如:
当我运行子报表时,它运行良好,但是多值参数的值由@CustomerID参数的值(使用数据集)确定,因此我无法选择有效值之外的值该客户的价值。
我已使用参数值(超出客户现有值)对SSMS子报表中的所有数据集运行了SQL。这些都很好。
我还尝试过在子报表中的数据集参数之间使用联接功能和不使用联接功能之间进行切换,但这无济于事。
我还尝试通过逗号分隔的列表通过以下查询从主报表中传递多值参数值,该列表将列表限制为对客户有效的值。这不能解决问题。
我很茫然,任何帮助将不胜感激。
IF OBJECT_ID('tempdb..#Data_Sub') IS NOT NULL DROP TABLE #Data_Sub;
Select distinct
CustomerID
,[AssignedToUser]
,null as OperationalArea
,null as SiteClass
Into
#Data_Sub
from
[FAMSDB].[dbo].[Incidents_Full_PI] as IFPI
inner join
(
select
item
from
[FAMSDB].[dbo].SplitToTable
(@CustomerID,',')
) as CID on IFPI.CustomerID = CID.item
where
ReportedFaultCode in ('SPD','SPO','SRD','SRO','SEO','SED')
and CASE when [AssignedToUser] in (select item from
FAMSDB.dbo.SplitToTable(@Assignedto,',')) then 1
else 0
end = 1
Union
Select distinct
CustomerID
,null
,OperationalArea
,null
from
[FAMSDB].[dbo].[Incidents_Full_PI] as IFPI
inner join
(
select
item
from
[FAMSDB].[dbo].SplitToTable
(@CustomerID,',')
) as CID on IFPI.CustomerID = CID.item
where
ReportedFaultCode in ('SPD','SPO','SRD','SRO','SEO','SED')
and CASE when [OperationalArea] in (select item from
FAMSDB.dbo.SplitToTable(@OperationalArea,',')) then 1
else 0
end = 1
Union
Select distinct
CustomerID
,null
,null
,SiteClass
from
[FAMSDB].[dbo].[Incidents_Full_PI] as IFPI
inner join
(
select
item
from
[FAMSDB].[dbo].SplitToTable
(@CustomerID,',')
) as CID on IFPI.CustomerID = CID.item
where
ReportedFaultCode in ('SPD','SPO','SRD','SRO','SEO','SED')
and CASE when [SiteClass] in (select item from
FAMSDB.dbo.SplitToTable(@SiteClass,',')) then 1
else 0
end = 1
union
select
item
,case when 'Unassigned' in (select item from
FAMSDB.dbo.SplitToTable(@Assignedto,',')) then 'Unassigned'
else null
end
,case when 'Unassigned' in (select item from
FAMSDB.dbo.SplitToTable(@OperationalArea,',')) then 'Unassigned'
else null
end
,case when 'Unassigned' in (select item from
FAMSDB.dbo.SplitToTable(@SiteClass,',')) then 'Unassigned'
else null
end
from
[FAMSDB].[dbo].SplitToTable (@CustomerID,',')
union
select
item
,case when 'N/A' in (select item from
FAMSDB.dbo.SplitToTable(@Assignedto,',')) then 'N/A'
else null
end
,case when 'N/A' in (select item from
FAMSDB.dbo.SplitToTable(@OperationalArea,',')) then 'N/A'
else null
end
,case when 'N/A' in (select item from
FAMSDB.dbo.SplitToTable(@SiteClass,',')) then 'N/A'
else null
end
from
[FAMSDB].[dbo].SplitToTable (@CustomerID,',')
Select
CustomerID
,AssignedToUser
,OperationalArea
,SiteClass
From
(
Select distinct
CustomerID
,case when len((Select [AssignedToUser]+',' From(Select
Distinct CustomerID,[AssignedToUser] From #Data_Sub) as b Where b.CustomerID
= a.CustomerID For XML Path('')))=0 then null
else LEft((Select
[AssignedToUser]+','
From
(
Select Distinct
CustomerID
,[AssignedToUser]
From
#Data_Sub
) as b
Where
b.CustomerID = a.CustomerID
For XML Path(''))
,len((Select
[AssignedToUser]+','
From
(
Select Distinct
CustomerID
,[AssignedToUser]
From
#Data_Sub
) as b
Where
b.CustomerID = a.CustomerID
For XML Path('')))-1
) end as AssignedToUser
,case when len((Select [OperationalArea]+',' From(Select
Distinct CustomerID,[OperationalArea] From #Data_Sub) as b Where
b.CustomerID = a.CustomerID For XML Path('')))=0 then null
else left((Select
[OperationalArea]+','
From
(
Select Distinct
CustomerID
,[OperationalArea]
From
#Data_Sub
) as b
Where
b.CustomerID = a.CustomerID
For XML Path('')),
lEn((Select
[OperationalArea]+','
From
(
Select Distinct
CustomerID
,[OperationalArea]
From
#Data_Sub
) as b
Where
b.CustomerID = a.CustomerID
For XML Path('')))-1
) end as OperationalArea
,case when len((Select [SiteClass]+',' From(Select
Distinct CustomerID,[SiteClass] From #Data_Sub) as b Where b.CustomerID =
a.CustomerID For XML Path('')))=0 then null
else Left((Select
[SiteClass]+','
From
(
Select Distinct
CustomerID
,[SiteClass]
From
#Data_Sub
) as b
Where
b.CustomerID = a.CustomerID
For XML Path(''))
,len((Select
[SiteClass]+','
From
(
Select Distinct
CustomerID
,[SiteClass]
From
#Data_Sub
) as b
Where
b.CustomerID = a.CustomerID
For XML Path('')))-1
) end as SiteClass
From
#Data_Sub as a
) as ConcatSub
where
AssignedToUser is not null
and OperationalArea is not null
and SiteClass is not null
编辑:我尚未通过删除返回多值参数值的数据集上的CustomerID过滤器来测试子报表。因此,他们现在可以选择对客户选择无效的参数值。子报表仍然可以正常运行。因此,问题一定在于如何将参数传递到子报表。
答案 0 :(得分:0)
此问题的解决方案似乎是结合了以下两种组合:使子报表能够选择未被CustomerID过滤的参数值,然后以[@Assignedto]形式而不是定界字符串或= Parameters!Assignedto.Value表单。
我分别尝试了这两种方法,都没有结果,但是当结合使用时,它们已经解决了问题。