简体   繁体   English

如何使用MDX仅获得独特的度量?

[英]How to get only unique measures using MDX?

I have an unconventional cube with a single dimension called 'RowNumber' and five measures called 'Col0', 'Col1' etc. Every coordinate of the cube is loaded with string values such as 'Value14' or 'Value3'. 我有一个非常规的多维数据集,具有一个名为“ RowNumber”的单一维度以及五个名为“ Col0”,“ Col1”等的度量。该多维数据集的每个坐标均加载有字符串值,例如“ Value14”或“ Value3”。

In each measure there will be repeats of the same string value, so if I execute 在每个小节中,都会重复相同的字符串值,所以如果我执行

SELECT [Measures].[Col2] ON 0, [RowNumber].[Row10]:[RowNumber].[Row14] ON 1 FROM [myCube]

I get these results: 我得到以下结果:

        Col2
Row10   Value5
Row11   Value0
Row12   Value0
Row13   Value19
Row14   Value6

You can see in the table above that there are two Value0 entries. 您可以在上表中看到两个Value0条目。 What I want to obtain is only the unique values from all of Col2, regardless of the RowNumber like this: 我想要获得的只是来自所有Col2的唯一值,而不管像这样的RowNumber:

Col2 
Value5 
Value0 
Value19 
Value6

I appreciate this is an unconventional use of a cube, so maybe it's not possible. 我赞赏这是对多维数据集的非常规用法,因此也许是不可能的。 However, getting the unique values from one measure does not seem like it should be impossible, so I hope there is a way to do this. 但是,从一种度量中获取唯一值似乎并非不可能,因此,我希望有一种方法可以做到这一点。

Thanks in advance. 提前致谢。

MDX isn't really designed for this kind of things. MDX并非真正针对此类事情而设计。 But it's possible: 但是有可能:

With
Set [OrderedRows] as 
Order(NonEmpty([RowNumber].[Row10]:[RowNumber].[Row14],[Measures].[Col2]),[Measures].[Col2])

Member [Measures].[Rank] as 
Rank([RowNumber].[RowNumber].CurrentMember, [OrderedRows])

Member [Measures].[Col2Unique] as 
IIF(
    ([OrderedRows].Item([Measures].[Rank] - 2),[Measures].[Col2]) = [Measures].[Col2],
    NULL,
    [Measures].[Col2]
)

Select {[Measures].[Col2],[Measures].[Col2Unique]} on 0,
Non Empty [OrderedRows] on 1
From [myCube]

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

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