简体   繁体   English

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

[英]How to pass multivalues parameters in MDX calculated members?

I'm actually working on a SSAS Cube using SQL Server Reporting Services. 我实际上正在使用SQL Server Reporting Services处理SSAS多维数据集。 In order to filter a field, I need to use a calculated member which specifically use a parameter. 为了过滤字段,我需要使用专门使用参数的计算成员。

Here is my calculated member: 这是我的计算成员:

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] 
)

This works well if @StockRoomCode only have one value. 如果@StockRoomCode仅具有一个值,则此方法效果很好。 But I don't know how to make it works when the parameter has multiple values. 但是我不知道当参数具有多个值时如何使其工作。 How to replace the 'xxx' ? 如何替换“ xxx”? Can you help me or tell me how to do it a better way, thanks ! 您能帮我还是告诉我如何做一个更好的方法,谢谢!

You could create a calculated member aggregating the members you want to report on and define the measure in tems of the calculated member, something like: 您可以创建一个计算成员,以汇总要报告的成员,并以该计算成员的项目定义度量,例如:

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])

(Note: not tested, just off the top of my head). (注意:未经测试,就在我的头顶上方)。 Or, 要么,

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]

Note, with either, get your set expression right and test that first. 注意,无论使用哪种方法,都要正确设置设置的表达式并首先对其进行测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM