如何在另一个 MDX 中使用 MDX 查询的结果?

How to use result of MDX query in another MDX?

我在 Microsoft Adventure Work DW 2012 上使用 MDX 查询并且我想要 [=43=每个 "country" 中 "Reseller Order Count" 的 ] 对于 "Australia"[=] 中 "Reseller Order Count" 大于 30 的 "product" 36=]

换句话说,

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

"Australia" 然后在 "Reseller Order Count" 中找到 "SUM" for the found "Product"s in other国家

措施是

[Measures].[Reseller Order Count]

尺寸为

[Geography].[Country].[Country]

[Product].[Product].[Product]

谢谢大家@};-

试试看:

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]

我认为您需要在 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];