【问题标题】:How to use result of MDX query in another MDX?如何在另一个 MDX 中使用 MDX 查询的结果?
【发布时间】:2017-05-13 11:07:20
【问题描述】:

我在 Microsoft Adventure Work DW 2012 上使用 MDX 查询,并且我希望在每个“国家”中获得“经销商订单计数”的 “SUM” 适用于“澳大利亚”中“经销商订单数”大于 30 的“产品”

换句话说,

首先我想找到 "Reseller Order Count" > 30 的 "Product"

“澳大利亚”,然后为在其他国家/地区找到的“产品”

找到“经销商订单数量”的“总和”

衡量标准是

[措施].[经销商订单数]

尺寸是

[地理].[国家].[国家]

[产品].[产品].[产品]

谢谢大家@};-

【问题讨论】:

    标签: mdx


    【解决方案1】:

    我认为您需要在 WITH 子句中执行 ozzy 过滤器,然后在 SELECT 中使用它:

    WITH
    SET [AustraliaProducts] AS
      FILTER(
        [Product].[Product].[Product].Members,
       ([Geography].[Country].&[Australia],[Measures].[Reseller Order Count]) > 30
      )
    SELECT 
      [Measures].[Reseller Order Count] ON 0,
      Non Empty 
        [Geography].[Country].[Country].MEMBERS
      * [AustraliaProducts] ON 1
    FROM [Adventure Work];
    

    我有点不确定结果中是否需要澳大利亚 - 如果不是,那么在 WITH 子句中进一步添加可以过滤掉澳大利亚:

    WITH
    SET [AustraliaProducts] AS
      FILTER(
        [Product].[Product].[Product].Members,
       ([Geography].[Country].&[Australia],[Measures].[Reseller Order Count]) > 30
      )
    SET [exclAustralia] AS
      EXCEPT(
        [Geography].[Country].[Country].MEMBERS,
        [Geography].[Country].&[Australia]
      )
    SELECT 
      [Measures].[Reseller Order Count] ON 0,
      Non Empty 
        [exclAustralia]
      * [AustraliaProducts] ON 1
    FROM [Adventure Work];
    

    【讨论】:

    • 非常感谢,对我帮助很大
    【解决方案2】:

    试试看:

    With 
    Member [Measures].[AustraliaProducts] as
    SUM(
        [Product].[Product].[Product].Members,
        IIF(
            ([Geography].[Country].&[Australia],[Measures].[Reseller Order Count]) > 30,
            [Measures].[Reseller Order Count],
            Null
        )
    )
    
    Select 
    [Measures].[AustraliaProducts] on 0,
    Non Empty [Geography].[Country].[Country].Members on 1
    From [Adventure Work]
    

    【讨论】:

    • 嗨,谢谢你的回复,但不是答案,我想通过 mdx 查询过滤产品,然后在另一个查询中使用该查询的结果,例如如果 [Australia] 有 [ Reseller Order Count]>30 for "produact A" and "product B" 然后我想知道其他国家的 [Reseller Order Count] 的总和,例如“US”,“Canada”,......仅这两种产品
    • 不好意思,我觉得你的回复也是正确的,非常感谢你:(我怎样才能选择两个答案正确?
    • 你不能。只选择最好的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多