结合两个计算的度量并使用组合结果在MDX中

时间:2014-01-23 06:35:17

标签: ssas mdx olap dimension measures

我正在创建两个不同的计算度量,我想使用两者的结果 来自同一个多维数据集的一个查询中的计算度量。

创建的计算度量之一是 -

With Member [Measures].[VenueSalesCost]
 as
 (
 [Measures].[Amount - Reporting Currency]
)
Select [Measures].[VenueSalesCost]
 on columns
 from  [Project accounting cube]
where 
[Chart of accounts].[Main account name].&[Venue Hire Costs]

,第二个是 -

 With Member [Measures].[VenueSalesAmount]
as (
[Measures].[Amount - Reporting Currency]
)
 Select [Measures].[VenueSalesAmount]
 on columns
 from  [Project accounting cube]
where 
[Chart of accounts].[Main account name].&[Rental of Venue]

现在我想在我的查询中使用这两个度量。请告诉我如何将这两个度量结合起来。

1 个答案:

答案 0 :(得分:0)

只需将不同查询的WHERE条件移动到计算度量的定义元组中即可:

With Member [Measures].[VenueSalesCost]
     as
     (
     [Chart of accounts].[Main account name].&[Venue Hire Costs],
     [Measures].[Amount - Reporting Currency]
     )
     Member [Measures].[VenueSalesAmount]
     as 
     (
     [Chart of accounts].[Main account name].&[Rental of Venue],
     [Measures].[Amount - Reporting Currency]
     )
     Member [Measures].[new Measure]
     as 
     [Measures].[VenueSalesCost] - [Measures].[VenueSalesAmount]
Select {
       [Measures].[VenueSalesCost],
       [Measures].[VenueSalesAmount],
       [Measures].[new Measure]
       }
       on columns
 from  [Project accounting cube]