SSRS中逗号分隔的文本输入参数(多个值)

时间:2015-12-02 09:29:13

标签: reporting-services parameters mdx ssrs-2012

我想输入(输入)多个值作为参数,用逗号分隔。例如:

enter image description here

我已将ProductArticle数据集更改为以下内容:

="WITH MEMBER [Measures].[ParameterCaption] AS [Product].
[Article].CURRENTMEMBER.MEMBER_CAPTION MEMBER [Measures].[ParameterValue] AS 
[Product].[Article].CURRENTMEMBER.UNIQUENAME MEMBER [Measures].[ParameterLevel] 
AS [Product].[Article].CURRENTMEMBER.LEVEL.ORDINAL SELECT {[Measures].
[ParameterCaption], [Measures].[ParameterValue], [Measures].[ParameterLevel]} 
ON COLUMNS, [Product].[Article].[Article].ALLMEMBERS ON ROWS FROM [Operational] 
where ([Product].[Article Key].&[" & Left(Parameters!ArticleInput.Value,5) 
& "], [Product].[Active].&[Active])"

我正在使用以下参数:

ArticleInput (available and default values not specified) ProductArticle (available and default values connected to the ProductArticle dataset)

enter image description here

这适用于一个参数输入,但我需要知道如何使用多个值来完成此工作。

2 个答案:

答案 0 :(得分:0)

尝试使用以下内容分割和重建字符串:

  "{" 
  +
  Replace(
    "[Product].[Article Key].&[" 
    + 
    Parameters!ArticleInput.Value
   , ","
   ,"],[Product].[Article Key].&["
  )
  +
  "]}"

通常使用MDX,您需要在执行上述操作时使用strToMemberstrToSet中的任何一个。

所以它会变成:

strToSet(
  "{" 
  +
  Replace(
    "[Product].[Article Key].&[" 
    + 
    Parameters!ArticleInput.Value
   , ","
   ,"],[Product].[Article Key].&["
  )
  +
  "]}"
,constrained
)

在sql中似乎可以进行类似的操作:

declare @x as varchar(250)
set @x = '112,113'

select
 Replace(
    '[Dim Branch].[HierarchyB-T-C].[Trading Code].&[' 
    + 
    @x
   , ','
   ,'],[Dim Branch].[HierarchyB-T-C].[Trading Code].&['
  )

结果:

enter image description here

所以你可以将dataset字符串修改为以下内容 - 我认为你需要将参数的数据类型更改为字符串而不是整数:

="WITH 
  MEMBER [Measures].[ParameterCaption] AS 
    [Product].[Article].CurrentMember.Member_Caption 
  MEMBER [Measures].[ParameterValue] AS 
    [Product].[Article].CurrentMember.UniqueName 
  MEMBER [Measures].[ParameterLevel] AS 
    [Product].[Article].CurrentMember.Level.Ordinal 
SELECT 
  {
    [Measures].[ParameterCaption]
   ,[Measures].[ParameterValue]
   ,[Measures].[ParameterLevel]
  } ON COLUMNS
 ,[Product].[Article].[Article].ALLMEMBERS ON ROWS
FROM [Operational]
WHERE 
  ({" 
  +
  Replace(
    "[Product].[Article Key].&[" 
    + 
    Parameters!ArticleInput.Value
   , ","
   ,"],[Product].[Article Key].&["
  )
  +
  "]}
   ,[Product].[Active].&[Active]
  );"

答案 1 :(得分:-2)

将“允许多个值”属性值设置为“报告参数”属性的“真” 并使用以下代码作为文本框中的表达式

=加入(参数!parameterName.Value, “”)