MDX - 多个位置和/或过滤条件

时间:2012-01-19 22:22:12

标签: sql filter mdx olap

我事先为一个看似基本的MDX问题道歉。我试图根据维度属性的多个组合过滤MDX结果集。

这是我的维度/度量布局:

尺寸:

[AccidentDate]
Year
Quarter
Month
Day
Date

[ItemInformation] 
ItemState

[CoverageInformation] 
CoverageHiearchy
----UserLine
--- Coverage Code

措施:

CTDPaid

现在,我希望从[CTDPaid]度量中选择总计金额,按[ItemInformation].ItemState属性分组。但是,我想根据多个过滤条件过滤此查询的结果集。

这些条件如下,并将分别评估

1. [CoverageInformation].[CoverageHiearchy].&[98]&[002] and [ItemInformation].ItemState.&[MI]
2. [CoverageInformation].[CoverageHiearchy].&[98]&[004] and [ItemInformation].ItemState.&[MI]
3. [CoverageInformation].[CoverageHiearchy].&[98]&[004] and [ItemInformation].ItemState.&[IL]
4. [CoverageInformation].[CoverageHiearchy].&[98]&[002] and [ItemInformation].ItemState.&[IL]

基本上,如果我将其移植到T-SQL where条件,它将构成以下内容:

,其中

  (ItemState = 'MI' and CoverageCode = '002' and UserLine = '98')

  (ItemState = 'MI' and CoverageCode = '004' and UserLine = '98')

  (ItemState = 'IL' and CoverageCode = '002' and UserLine = '98')

  (ItemState = 'IL' and CoverageCode = '004' and UserLine = '98')

将它放入MDX切片器将无法正常工作,因为我认为不支持跨同一层次结构的交叉连接。

使用过滤器()MDX功能对我来说也不起作用。

我非常感谢协助制定正确的MDX查询以正确过滤我的结果集,如上所述。

非常感谢你的时间

1 个答案:

答案 0 :(得分:2)

试试这个解决方案:

SELECT 
     {...} On Columns,
     {...} On Rows
FROM  (Select 
{([CoverageInformation].[CoverageHiearchy].&[98]&[002], [ItemInformation].ItemState.&[MI]),
 ([CoverageInformation].[CoverageHiearchy].&[98]&[004], [ItemInformation].ItemState.&[MI])
 ([CoverageInformation].[CoverageHiearchy].&[98]&[004], [ItemInformation].ItemState.&[IL])
 ([CoverageInformation].[CoverageHiearchy].&[98]&[002], [ItemInformation].ItemState.&[IL])} On Columns
From [CubeName])