MDX- CALCULATION BY ITEM()

WITH MEMBER [measures].[First Year Internet Sales Amount] 
AS    
     {{[Date].[Calendar Year].&[2006],[Date].[Calendar Year].&[2007],[Date].[Calendar Year].&[2008]}     
       *{ [Measures].[Internet Sales Amount]}
      }.Item (0) // Item(0) is used to get the first year measure
   , FORMAT_STRING = "Currency"
   , SOLVE_ORDER = 1
MEMBER [measures].[Variance]  AS
(
[Measures].[Internet Sales Amount] - [measures].[First Year Internet Sales Amount]
)
, SOLVE_ORDER = 2
MEMBER [Measures].[PercentageVariance] AS
(
CASE WHEN [measures].[First Year Internet Sales Amount] IS NULL 
OR ISEMPTY([measures].[First Year Internet Sales Amount]) THEN 1
     WHEN [measures].[Internet Sales Amount] IS NULL THEN -1
ELSE [measures].[Variance] 
 /
[measures].[First Year Internet Sales Amount] 
END )
,FORMAT_STRING = "Percent"
, SOLVE_ORDER = 3  
SELECT 
   {  [measures].[First Year Internet Sales Amount],[Measures].[Internet Sales Amount] 
     , [measures].[Variance],[Measures].[PercentageVariance]
    }
  ON 0
, [Date].[Calendar Year].children ON ROWS
FROM 
(select 
{[Date].[Calendar Year].&[2006],[Date].[Calendar Year].&[2007],[Date].[Calendar Year].&[2008]} on 0 
from 
[Adventure Works]
)

First Year Internet Sales AmountInternet Sales AmountVariancePercentageVariance
CY 2006$6,530,343.53$6,530,343.53$0.000.00%
CY 2007$6,530,343.53$9,791,060.30$3,260,716.7749.93%
CY 2008$6,530,343.53$9,770,899.74$3,240,556.2149.62%
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值