在 MDX 查询中获取记录键

Get record keys in MDX query

我有一个问题

WITH
MEMBER Measures.ProductKey as [Hand].[Name1].Currentmember.Member_Key
SELECT NON EMPTY
{ [Measures].[Netto], [Measures].[Cost], Measures.ProductKey } Dimension Properties CHILDREN_CARDINALITY,
PARENT_UNIQUE_NAME ON COLUMNS,
NON EMPTY
{ [Hand].[Nazwa1], [Hand].[Nazwa1].Children } Dimension Properties CHILDREN_CARDINALITY,
PARENT_UNIQUE_NAME ON ROWS
FROM [Bild]

此查询 return Netto、Cost 和 Key。但是当 Netto 和 Cost 为空时,我不想显示这条记录。没有措施。 ProductKey 很好,但我没有密钥。

对计算成员 ProductKey 的代码进行如下小改动:

WITH
MEMBER Measures.ProductKey as 
IIF([Measures].[Netto] = NULL AND [Measures].[Cost] = NULL, NULL, [Hand].[Name1].Currentmember.Member_Key)

//Here have added a condition which first checks the values of other two measures. 
//If they are NULL, it sets the value of ProductKey as NULL as well. 
//The NON EMPTY clause then does its job of removing the row of data from output.

SELECT NON EMPTY
{ [Measures].[Netto], [Measures].[Cost], Measures.ProductKey } Dimension Properties CHILDREN_CARDINALITY,
PARENT_UNIQUE_NAME ON COLUMNS,
NON EMPTY
{ [Hand].[Nazwa1], [Hand].[Nazwa1].Children } Dimension Properties CHILDREN_CARDINALITY,
PARENT_UNIQUE_NAME ON ROWS
FROM [Bild]