使用 MDX 将 SSAS 成员分组到桶中
Grouping SSAS members into buckets using MDX
这里是 SSAS 和 MDX 新手。
如果我有一个 SSAS 多维数据集,其中地理、产品作为维度,总销售额作为度量。
以下元素在地理位置下:
EAST
WEST
NORTH
SOUTH
MID-ATLANTIC
MOUNTAIN
NORTH-WEST
产品是:
1
2
3
4
对于产品 ID = 1,有没有办法可以将一些成员分组到一个 "rest of the country" 桶中并汇总销售额?
意思是,预期的输出是:
Product ID Geography Sales
1 East 100
1 West 200
1 North 300
1 South 400
1 RestOfNation 1200
2 East 100
2 West 50
2 RestOfNation 1500
有没有一种方法可以使用 MDX 查询将一些成员加入 "RestOfNation"?
你可以尝试这样的事情。
- 创建一个命名集,其中包含您要放入桶中的成员
RestOfWorld
。
- 做一个会员,在地理维度内,就是世界其他会员的集合。
- 找出不在世界其他地区集合中的国家。
这是一个针对 AdvWrks
的脚本(值得安装,因为它是玩 mdx 和发帖到论坛时常用的原型制作工具):
WITH
SET [RestOfWorld] AS
{
[Customer].[Customer Geography].[Country].&[United Kingdom]
,[Customer].[Customer Geography].[Country].&[Germany]
}
MEMBER [Customer].[Customer Geography].[All].[RestOfWorld] AS
Aggregate
(
{
[Customer].[Customer Geography].[Country].&[United Kingdom]
,[Customer].[Customer Geography].[Country].&[Germany]
}
)
SET [CountriesMinusROW] AS
[Customer].[Customer Geography].[Country].MEMBERS - [RestOfWorld]
SELECT
NON EMPTY
{[Measures].[Internet Sales Amount]} ON 0
,NON EMPTY
[Product].[Category].[Category]
*
{
[CountriesMinusROW]
,[Customer].[Customer Geography].[All].[RestOfWorld]
} ON 1
FROM [Adventure Works]
WHERE
[Date].[Calendar Year].&[2007];
以上给出了以下cellset
:
这里是 SSAS 和 MDX 新手。
如果我有一个 SSAS 多维数据集,其中地理、产品作为维度,总销售额作为度量。
以下元素在地理位置下:
EAST
WEST
NORTH
SOUTH
MID-ATLANTIC
MOUNTAIN
NORTH-WEST
产品是:
1
2
3
4
对于产品 ID = 1,有没有办法可以将一些成员分组到一个 "rest of the country" 桶中并汇总销售额?
意思是,预期的输出是:
Product ID Geography Sales
1 East 100
1 West 200
1 North 300
1 South 400
1 RestOfNation 1200
2 East 100
2 West 50
2 RestOfNation 1500
有没有一种方法可以使用 MDX 查询将一些成员加入 "RestOfNation"?
你可以尝试这样的事情。
- 创建一个命名集,其中包含您要放入桶中的成员
RestOfWorld
。 - 做一个会员,在地理维度内,就是世界其他会员的集合。
- 找出不在世界其他地区集合中的国家。
这是一个针对 AdvWrks
的脚本(值得安装,因为它是玩 mdx 和发帖到论坛时常用的原型制作工具):
WITH
SET [RestOfWorld] AS
{
[Customer].[Customer Geography].[Country].&[United Kingdom]
,[Customer].[Customer Geography].[Country].&[Germany]
}
MEMBER [Customer].[Customer Geography].[All].[RestOfWorld] AS
Aggregate
(
{
[Customer].[Customer Geography].[Country].&[United Kingdom]
,[Customer].[Customer Geography].[Country].&[Germany]
}
)
SET [CountriesMinusROW] AS
[Customer].[Customer Geography].[Country].MEMBERS - [RestOfWorld]
SELECT
NON EMPTY
{[Measures].[Internet Sales Amount]} ON 0
,NON EMPTY
[Product].[Category].[Category]
*
{
[CountriesMinusROW]
,[Customer].[Customer Geography].[All].[RestOfWorld]
} ON 1
FROM [Adventure Works]
WHERE
[Date].[Calendar Year].&[2007];
以上给出了以下cellset
: