如何进行MDX除了交叉连接维度查询

时间:2014-09-03 07:33:30

标签: ssas mdx

考虑以下数据。我想得到NON {国家:美国&性别:F}使用MDX

- - - - - - - - - -  - - - - - - - - - - - 
| Country     |    Gender     |   Sales   |        
- - - - - - - - - -  - - - - - - - - - - - 
USA               M                1000
USA               F                500
Spain             M                200
Spain             F                600

我想要提取的是:

- - - - - - - - - -  - - - - - - - - - - - 
| Country     |    Gender     |   Sales   |        
- - - - - - - - - -  - - - - - - - - - - - 
USA               M                1000
Spain             M                200
Spain             F                600

我尝试使用crossjoin,union和除此之外,例如。


    WITH SET [Test] AS
    [Country].[CountryCode].[USA] * Except ([Gender].members,{[Gender].[GenderCode].[F]}) +
    Except([Country].[CountryCode].members, {[Country].[CountryCode].[USA]}) * [Gender].members
    SELECT
       NON EMPTY [Test] ON ROWS,
       {[Measures].[Sales]} ON COLUMNS
        FROM [SalesCube]

它有效,但我可以知道是否还有其他更简单的方法吗?

感谢。

1 个答案:

答案 0 :(得分:1)

如果你想排除几个组合,你可以在交叉连接上使用Except和例外组合作为这样的元组:

WITH SET [Test] AS
Except(CrossJoin([Country].[CountryCode].members,
                 [Gender].members
                ),
       { ([Country].[CountryCode].[USA], [Gender].[GenderCode].[F]) }
      )
...

从语法上讲,您将CrossJoin缩写为*,将Except缩写为-,将Union缩写为+通常的优先规则(*的优先级高于-+):

WITH SET [Test] AS
[Country].[CountryCode].members * [Gender].[GenderCode].members
-
{ ([Country].[CountryCode].[USA], [Gender].[GenderCode].[F]) }
...
相关问题