如何在MDX计算成员中传递多值参数?

时间:2011-04-18 12:56:52

标签: sql-server ssrs-2008 ssas mdx

我实际上正在使用SQL Server Reporting Services处理SSAS多维数据集。 为了过滤字段,我需要使用专门使用参数的计算成员。

这是我的计算成员:

WITH MEMBER [Measures].[Comparable Stock Room] AS Iif (
    [Stock room].[Stock room code].currentMember IS (Iif (STRTOMEMBER(@StockRoomCode).Count = 1, STRTOMEMBER(@StockRoomCode), xxx)),
    0,
    [Measures].[Retail sales amount invoiced including tax] 
)

如果@StockRoomCode只有一个值,这很有效。但是当参数有多个值时,我不知道如何使它工作。如何更换'xxx'? 你能帮助我,或者告诉我如何更好地做到这一点,谢谢!

1 个答案:

答案 0 :(得分:1)

您可以创建一个聚合您要报告的成员的计算成员,并定义计算成员的时间度量,例如:

with member [Stock Room].[Stock room code].[foo] as
aggregate (strtoset (@StockRoomCode)),

member [Measures].[Comparable Stock Room] as
([Stock Room].[Stock room code].[foo],
 [Measures].[Retail sales amount including tax])

(注意:未经测试,只是在我的头顶)。或者,

with set [foo] as strtoset (@StockRoomCode),

member [Measures].[Comparable Stock Room] as
       sum ([foo], [Measures].[Retail sales amount including tax])

select [Measures].[Comparable Stock Room] on columns,
       (Slicing dimension such as time) on rows
  from [cube]
 where [other slice]

注意,使用其中任何一个,获取你的set表达式并首先测试它。