How to pass multivalues parameters in MDX calculated members?
I'm actually working on a SSAS Cube using SQL Server Reporting Services. 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 amo开发者_运维知识库unt invoiced including tax]
)
This works well if @StockRoomCode only have one value. But I don't know how to make it works when the parameter has multiple values. How to replace the '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.
精彩评论