如何使用MDX过滤String中的列表

时间:2013-12-06 16:14:30

标签: reporting-services mdx

目标:
根据字符串“Canada”作为条件过滤表格列中的值。

问题:
我无法在状态正确的地方获取MDX语法代码,以便根据Canada过滤数据。

信息:

  • 这种情况是一个简化的示例,我的请求是在where状态中添加过滤条件。
  • 数据源是SSAS:s AdventureWorksDW2012

代码:

SELECT
{ 
    [Measures].[Reseller Order Count], 
    [Measures].[Discount Amount] 

} ON COLUMNS, 
{ 
    ([Reseller].[Reseller Type].[Business Type].ALLMEMBERS ) 
} ON ROWS 
FROM  [Adventure Works]
WHERE
(
    FILTER
    (
                [Geography].[Country].ALLMEMBERS, [Geography].[Country].NAME ='Canada'
    )
)

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:0)

有两个问题:

  1. 在Adventure Works中,Geography维度未与Internet Sales度量值组相关联。查看多维数据集定义,选项卡“维度用法”。在使用Customer度量值组中的度量时,应使用Location文件夹中Internet Sales维度中的层次结构。我在下面使用[Customer].[Country]

  2. 在过滤器中,您应该使用Current和设置别名来引用集合迭代期间的当前元素。

  3. 以下显示了您想要的内容,我刚刚更改了Filter

    SELECT
    { 
        [Measures].[Reseller Order Count], 
        [Measures].[Discount Amount] 
    
    } ON COLUMNS, 
    { 
        ([Reseller].[Reseller Type].[Business Type].ALLMEMBERS ) 
    } ON ROWS 
    FROM  [Adventure Works]
    WHERE
    (
        FILTER
        (
                    [Customer].[Country].ALLMEMBERS as c, c.current.NAME ='Canada'
        )
    )