在行上,我基本上想选择层次结构的所有成员,但想将其中的两个合并为一个。例如,成员将包括 A
, B
, 和 C
,所以选择 [Group].[Group].members
会给我All
, A
, B
, 和 C
但我想得到 All, A,
和 B&C
,其中 B
和 C
已合并为一个成员。
这在查询中可能吗?
我正在使用的数据库存储有关订单运输速度、小包裹、小于卡车装载量和白手套的信息。我想合并小包裹和小于卡车的装载量,以便我可以获得两种运输速度的汇总数据。
我尝试创建一个计算成员:[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.
有没有更好的方法来解决这个问题/那个错误是什么意思?
最佳答案
您看到的错误是由于您的括号语法引起的:(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]
结果:
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 - 如何在查询中将两个成员合并为一个?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17682164/