如何在查询中将两个成员合并为一个?

Tra*_*vis 6 mdx

在行上,我基本上想要选择层次结构的所有成员,但希望将它们中的两个合并为一个.例如,成员将包括A,B,和C,因此选择[Group].[Group].members都会给我All,A,B,和C,但我想获得All, A,B&C,其中BC已合并为一个成员.

这可能在查询中吗?

我正在使用的数据库存储有关订单运输速度,小包裹,小于卡车装载和白色手套的信息.我想合并小包裹而不是卡车装载,这样我就可以获得两种运输速度的汇总数据.

我尝试创建一个计算成员:[Measures].[Not White Glove] as AGGREGATE([Order Product].[Ships Via Group].&[Small Parcel], [Order Product].[Ships Via Group].&[Less than Truck Load])但我不确定如何使用它,因为我现在有[Order Product].[Ships Via Group].members ON ROWS.

当我把([Measures].[Not White Glove], [Order Product].[Ships Via Group].&[White Glove], [Order Product].[Ships Via Group].&[All]) ON ROWS我得到错误Query (14, 11) The Ships Via Group hierarchy is used more than once in the Crossjoin function.

有没有更好的方法来解决这个问题/错误是什么意思?

fin*_*ngo 12

您看到的错误是因为您使用括号的语法:(a, b, c)定义一个元组,其中a,b和c是来自不同维度的每个成员.如果你想把这些成员联合在一起,你应该用速记:{a, b, c}.

现在,组合成员是可能的,虽然可能不像你想要的那样干净和简单.以下是一种方法的示例,通过创建新成员然后Except从层次结构中排除(通过)原始成员.

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]
Run Code Online (Sandbox Code Playgroud)

结果:

                  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
Run Code Online (Sandbox Code Playgroud)

希望这有助于您走上正轨.