首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MDX查询:如果虚集与其他维度无关,如何在查询结果中显示?

问MDX查询:如果虚集与其他维度无关,如何在查询结果中显示?
EN

Stack Overflow用户
提问于 2017-08-19 18:19:06
回答 1查看 149关注 0票数 0

需要你的帮助来解决客户报告中的一个问题。

请检查下面2个mdx查询的结果。

注意:我使用了Union运算符,这样我就可以将2个成员的结果与1合并(法国和德国加在一起)。在Union中使用Exist函数,因为如果第一个集合与第二个集合的维度成员相关,则需要检查函数中的第一个集合。

我使用Union with Exist来实现OR条件。

在第一个MDX查询中,您可以在结果集中找到虚拟集(法国和德国),但在第二个MDX中,您无法找到虚拟集(法国和德国),因为Product Category hierarchy与country和Exist函数相关,检查虚拟集不是国家层次结构的实际成员,因此它将从结果集中删除虚拟集。

有没有什么方法或替代方法可以让我强制exists函数在最终结果(mDX 2)中显示虚拟集?

有没有什么方法或替代方法可以让我强制exists函数在最终结果(mDX 2)中显示虚拟集?

MDX 1)

代码语言:javascript
复制
WITH 
    SET [Combined] AS {
        [Customer].[Customer Geography].[Country].&[France], 
        [Customer].[Customer Geography].[Country].&[Germany]
    }
    MEMBER [Customer].[Customer Geography].[France & Germany] AS Aggregate([Combined])
SELECT
    [Measures].[Internet Sales Amount] ON 0,
    Union(
        Except([Customer].[Customer Geography].[Country], [Combined]),
        [Customer].[Customer Geography].[France & Germany]
    ) ON 1
FROM [Adventure Works]

结果MDX 1

代码语言:javascript
复制
Internet Sales Amount
Australia   $9,061,000.58
Canada  $1,977,844.86
United Kingdom  $3,391,712.21
United States   $9,389,789.51
France & Germany    $5,538,330.05

MDX查询2)

代码语言:javascript
复制
WITH 
    SET [Combined] AS {
        [Customer].[Customer Geography].[Country].&[France], 
        [Customer].[Customer Geography].[Country].&[Germany]
    }
    MEMBER [Customer].[Customer Geography].[France & Germany] AS Aggregate([Combined])
SELECT
    [Measures].[Internet Sales Amount] ON 0,

       Union( Exists(Except([Customer].[Customer Geography].[Country], [Combined]),
        {[Product].[Product Categories].[Category].&[3]}  
        , "Internet Sales") ,

      Exists([Customer].[Customer Geography].[France & Germany],{[Product].[Product Categories].[Category].&[3]}  
     , "Internet Sales"))

     ON 1
FROM [Adventure Works]

结果MDX查询2)

代码语言:javascript
复制
Internet Sales Amount
Australia        $9,061,000.58
Canada          $1,977,844.86
United Kingdom  $3,391,712.21
United States   $9,389,789.51
EN

回答 1

Stack Overflow用户

发布于 2017-08-21 07:06:17

为什么在第二个查询中需要使用exists两次?

代码语言:javascript
复制
WITH 
    SET [Combined] AS {
        [Customer].[Customer Geography].[Country].&[France], 
        [Customer].[Customer Geography].[Country].&[Germany]
    }
    MEMBER [Customer].[Customer Geography].[France & Germany] AS Aggregate([Combined])
SELECT
    [Measures].[Internet Sales Amount] ON 0,

       Union( 
         Exists(
           Except([Customer].[Customer Geography].[Country], [Combined]),
           {[Product].[Product Categories].[Category].&[3]}  
          ,"Internet Sales"
         )

        //,Exists(
        //   [Customer].[Customer Geography].[France & Germany]
        // ,{[Product].[Product Categories].[Category].&[3]}  
        // ,"Internet Sales"
        // )

        ,[Customer].[Customer Geography].[France & Germany]

       )    
     ON 1
FROM [Adventure Works];
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45770349

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档