How can I merge two members into one in a query?

别来无恙 提交于 2019-11-30 20:51:39

The error you're seeing is because of your syntax with the parentheses: (a, b, c) defines a tuple where a, b, and c are each members from a different dimension. If you're trying to union these members together, you should use the shorthand: {a, b, c}.

Now, to combine the members is possible, although maybe not as clean and easy as you would want. Here's an example of one way to do it, by creating a new member and then excluding (via Except) the original members from the hierarchy.

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]

Results:

                  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

Hope that helps set you on the right track.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!