MDX - 通过另一个成员值设置成员
MDX - set member by another member values
我用 MDX 生成了这个 table。
http://i62.tinypic.com/2m5xeg0.jpg
我需要创建一个名为 "this year" 的计算维度(或度量),其中包含 2 个值:
是:如果当前成员 YEAR 包含值 2015 和
否:如果成员 YEAR 不包括每个 CLIENT ID 的 2015
http://i57.tinypic.com/2h508yx.jpg
MDX 代码为:
SELECT
NON EMPTY {[Measures].[QUANTITY]} ON COLUMNS,
NON EMPTY CrossJoin({CLIENT ID].[CLIENT ID].Members, {[YEAR].[YEAR].Members}) ON ROWS
FROM
[MyCube]
您可以尝试以下操作:
WITH
MEMBER [Measures].[is2015] AS
IIF
(
Isnull(Instr(0,[YEAR].[YEAR].CurrentMember.Member_Caption,"2015")) //<<unsure if the 2nd argumnet should read: [YEAR].CurrentMember.Member_Caption
,"YES"
,"NO"
)
SELECT
NON EMPTY
{
[Measures].[QUANTITY]
,[Measures].[is2015]
} ON COLUMNS
,NON EMPTY
CrossJoin
(
[CLIENT ID].[CLIENT ID].MEMBERS
,{[YEAR].[YEAR].MEMBERS}
) ON ROWS
FROM [MyCube];
这是 mdx
中使用的 Instr
函数的 MSDN
文档:
https://msdn.microsoft.com/en-us/library/hh758424.aspx
参考您的屏幕打印,请尝试以下替代方法:
WITH
MEMBER [Measures].[is2015] AS
IIF
(
NonEmpty
(
[CLIENT ID].[CLIENT ID].CurrentMember
,[YEAR].[YEAR].[2015]
).Count
> 0
,"YES"
,"NO"
)
SELECT
NON EMPTY
{
[Measures].[QUANTITY]
,[Measures].[is2015]
} ON COLUMNS
,NON EMPTY
CrossJoin
(
[CLIENT ID].[CLIENT ID].MEMBERS
,{[YEAR].[YEAR].MEMBERS}
) ON ROWS
FROM [MyCube];
非常感谢!替代答案在蒙德里安中运行得非常好,只需很少的改动:
WITH
MEMBER [Measures].[is2015] AS
IIF
(
(
[CLIENT ID].CurrentMember
,[YEAR].[2015]
)
> 0
,"YES"
,"NO"
)
SELECT
NON EMPTY
{
[Measures].[QUANTITY]
,[Measures].[is2015]
} ON COLUMNS
,NON EMPTY
CrossJoin
(
[CLIENT ID].[CLIENT ID].MEMBERS
,{[YEAR].[YEAR].MEMBERS}
) ON ROWS
FROM [MyCube];
我用 MDX 生成了这个 table。
http://i62.tinypic.com/2m5xeg0.jpg
我需要创建一个名为 "this year" 的计算维度(或度量),其中包含 2 个值:
是:如果当前成员 YEAR 包含值 2015 和
否:如果成员 YEAR 不包括每个 CLIENT ID 的 2015
http://i57.tinypic.com/2h508yx.jpg
MDX 代码为:
SELECT NON EMPTY {[Measures].[QUANTITY]} ON COLUMNS, NON EMPTY CrossJoin({CLIENT ID].[CLIENT ID].Members, {[YEAR].[YEAR].Members}) ON ROWS FROM [MyCube]
您可以尝试以下操作:
WITH
MEMBER [Measures].[is2015] AS
IIF
(
Isnull(Instr(0,[YEAR].[YEAR].CurrentMember.Member_Caption,"2015")) //<<unsure if the 2nd argumnet should read: [YEAR].CurrentMember.Member_Caption
,"YES"
,"NO"
)
SELECT
NON EMPTY
{
[Measures].[QUANTITY]
,[Measures].[is2015]
} ON COLUMNS
,NON EMPTY
CrossJoin
(
[CLIENT ID].[CLIENT ID].MEMBERS
,{[YEAR].[YEAR].MEMBERS}
) ON ROWS
FROM [MyCube];
这是 mdx
中使用的 Instr
函数的 MSDN
文档:
https://msdn.microsoft.com/en-us/library/hh758424.aspx
参考您的屏幕打印,请尝试以下替代方法:
WITH
MEMBER [Measures].[is2015] AS
IIF
(
NonEmpty
(
[CLIENT ID].[CLIENT ID].CurrentMember
,[YEAR].[YEAR].[2015]
).Count
> 0
,"YES"
,"NO"
)
SELECT
NON EMPTY
{
[Measures].[QUANTITY]
,[Measures].[is2015]
} ON COLUMNS
,NON EMPTY
CrossJoin
(
[CLIENT ID].[CLIENT ID].MEMBERS
,{[YEAR].[YEAR].MEMBERS}
) ON ROWS
FROM [MyCube];
非常感谢!替代答案在蒙德里安中运行得非常好,只需很少的改动:
WITH MEMBER [Measures].[is2015] AS IIF ( ( [CLIENT ID].CurrentMember ,[YEAR].[2015] ) > 0 ,"YES" ,"NO" ) SELECT NON EMPTY { [Measures].[QUANTITY] ,[Measures].[is2015] } ON COLUMNS ,NON EMPTY CrossJoin ( [CLIENT ID].[CLIENT ID].MEMBERS ,{[YEAR].[YEAR].MEMBERS} ) ON ROWS FROM [MyCube];