我在多维数据集(SSAS 2014)中有数据,如下所示:
Dim1 Dim2 Dim3 Meas1
Alpha Marco Chicago 10
Alpha Polo Atlanta 15
Alpha Marco Chicago 17
Beta Polo New York 21
Beta Marco Atlanta 31
Beta Polo Chicago 41
如何编写MDX查询以获得这样的结果?
Dim1 Dim2 ChicagoTotl/AtlantaTotl/NewYorkTotl
Alpha Marco 27 / 0 / 0
Alpha Polo 0 / 15 / 0
Beta Marco 0 / 31 / 0
Beta Polo 41 / 0 / 21
---
135
在报告Dim1& Dim2将成为用户可选择的过滤器。
但是如何将Dim3作为单独的列标记出来?
这个MDX是什么样子的?以这种方式完成的列是否有名称?你叫我什么?
感谢您的帮助。
答案 0 :(得分:1)
您可以这样做:
WITH
MEMBER [Measures].[ChicagoTotal] AS
(
[Measures].[Meas1]
,[Dim3].[Hierarchy].[Chicago]
)
MEMBER [Measures].[NewYorkTotal] AS
(
[Measures].[Meas1]
,[Dim3].[Hierarchy].[New York]
)
MEMBER [Measures].[AtlantaTotal] AS
(
[Measures].[Meas1]
,[Dim3].[Hierarchy].[Atlanta]
)
SELECT
NON EMPTY
{
[Measures].[ChicagoTotal]
,[Measures].[NewYorkTotal]
,[Measures].[AtlantaTotal]
} ON 0
,NON EMPTY
[Dim1].[Hierarchy].MEMBERS * [Dim2].[Hierarchy].MEMBERS ON 1
FROM [YourCube];
答案 1 :(得分:1)
假设Meas1的聚合类型为Sum。然后查询将是这样的:
SELECT [Dim3].[Hier3].MEMBERS on 0,
[Dim1].[Hier1].MEMBERS * [Dim2].[Hier2].MEMBERS on 1
FROM [Cube] WHERE ([Measures].[Meas1])
此查询将根据Dim3.Hier3中的成员自动创建列。