考虑以下数据。我想使用 MDX 获取 NON{Country:USA & Gender:F}
- - - - - - - - - - - - - - - - - - - - - | 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 和 except 来做到这一点,例如
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]
它有效,但我可以知道是否还有其他更简单的方法吗?
谢谢。
最佳答案
如果你想排除一些组合,你可以在交叉连接上使用 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]) }
...
关于ssas - 如何进行 MDX 除了交叉连接维度查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25638706/