SSRS mdx报告:通过多值参数的最大排名值的计算成员

时间:2016-03-30 18:42:50

标签: reporting-services parameters mdx olap member

这是对MS OLAP多维数据集的一个简单的mdx查询,它输出3个城市的销售步骤统计数据,每个销售阶段的排名,它工作正常:

WITH 
MEMBER [Measures].[rank] AS 

    case [Sales_step].currentmember.member_caption         
    when 'Contacts' then 1    
    when 'Clients' then 2
    when 'Funded' then 3 
    else 0 end

SELECT {[Measures].[rank],
        [Measures].[qnt]} ON COLUMNS,

NON EMPTY     
       crossjoin({[City].CHILDREN},                            
                 {[Sales_step].CHILDREN}) ON ROWS 

FROM ( SELECT ( STRTOSET(@[Sales_step], CONSTRAINED) ) ON COLUMNS  
FROM [SALES_PIPE])

输出结果为:

enter image description here

现在我想为每个城市建立总计而没有单独的销售步骤,但仅显示最大的存档销售阶段排名。结果必须是:

enter image description here

我尝试了以下代码来执行此操作:

WITH 
MEMBER [Measures].[rank max] AS 

    case [Sales_step].currentmember.member_caption         
    when 'Contacts' then 1    
    when 'Clients' then 2
    when 'Funded' then 3 
    else 0 end

SELECT {[Measures].[rank max],
        [Measures].[qnt]} ON COLUMNS,

NON EMPTY [City].CHILDREN ON ROWS 

FROM ( SELECT ( STRTOSET(@[Sales_step], CONSTRAINED) ) ON COLUMNS  
FROM [SALES_PIPE])

它不会生成错误,但会为计算成员[Measures]返回空值。[rank max]:

enter image description here

仅当我将一个值传递给@ [Sales_step]参数时才有效。虽然我需要一个多值的参数运行。当我在case子句中更改了这个片段时:

case [Sales_step].currentmember.member_caption 

为:

case strtomember(@[Sales_step]).member_caption

它抛出错误“STRTOMEMBER函数需要1参数的成员表达式。使用了元组集表达式”。当我使用它时,错误也会触发单参数和多参数:

case strtoset(@[Sales_step]).currentmember.member_caption

我如何修改计算成员[Measures]。[rank max]以获得所需的结果,并且传递@ [Sales_step]多值参数的最大等级?

1 个答案:

答案 0 :(得分:2)

我想知道这样的事情是否有效:

WITH 
SET [S] AS
    NonEmpty(
       EXISTING [Sales_step].CHILDREN,
       ([City].CURRENTMEMBER, [Measures].[qnt])   //<<I think that [City].CURRENTMEMBER is probably redundant in this tuple
    )
MEMBER [Mx] AS   
    CASE         
      WHEN INTERSECT([S], {[Sales_step].[Funded]}).COUNT = 1 THEN 3 
      WHEN INTERSECT([S], {[Sales_step].[Clients]}).COUNT = 1 THEN 2 
      WHEN INTERSECT([S], {[Sales_step].[Contacts]}).COUNT = 1 THEN 1
    END 
...
...