SSRS老化报告MDX查询

时间:2014-12-11 07:27:13

标签: reporting-services mdx

我想生成老化报告。

  • 列表项

下面是我的MDX查询。但它给出了每个时期的累计金额。我希望结果像

          0-30 Days     30-60 Days    60-90 Days     > 90 Days

Customer 1   15          8             11              120
Customer 2   32         21             7                75

-------------------------------------------------------------------

With
Member [Measures].[0-30] as
Sum(
ClosingPeriod([Cal Date].[Month].[Month], [Cal Date].[Month].[All]).Lag(1)
: ClosingPeriod([Cal Date].[Month].[Month], [Cal Date].[Month].[All].Lag(0))
,[Measures].[Master Count] )

Member [Measures].[31-60] as
ClosingPeriod([Cal Date].[Month].[Month], [Cal Date].[Month].[All]).Lag(2)
: ClosingPeriod([Cal Date].[Month].[Month], [Cal Date].[Month].[All].Lag(1))
,[Measures].[Master Count] )

Member [Measures].[61-90] as
Sum(
ClosingPeriod([Cal Date].[Month].[Month], [Cal Date].[Month].[All]).Lag(3)
: ClosingPeriod([Cal Date].[Month].[Month], [Cal Date].[Month].[All].Lag(2))
,[Measures].[Master Count] )

select
{[Measures].[0-30], [Measures].[31-60], [Measures].[61-90] } on 0,
{
[Customer].[Name].[Name].Allmembers
} on 1
from [My Cube]

1 个答案:

答案 0 :(得分:0)

你的脚本对我来说没问题。尝试将closingperiod部分转换为自定义设置:

With
set [x] as
  {ClosingPeriod([Cal Date].[Month].[Month], [Cal Date].[Month].[All])}
Member [Measures].[0-30] as
  Sum(
   [x].item(0).Lag(1) : [x].item(0).Lag(0)
   ,[Measures].[Master Count] 
  )
Member [Measures].[31-60] as
  Sum(
   [x].item(0).Lag(2) : [x].item(0).Lag(1)
   ,[Measures].[Master Count] 
  )
Member [Measures].[61-90] as
  Sum(
   [x].item(0).Lag(3) : [x].item(0).Lag(2)
   ,[Measures].[Master Count] 
  )
Member [Measures].[90-120] as
  Sum(
   [x].item(0).Lag(4) : [x].item(0).Lag(3)
   ,[Measures].[Master Count] 
  )
Member [Measures].[>120] as
  Sum(
   null : [x].item(0).Lag(4)
   ,[Measures].[Master Count] 
  )
select
 {[Measures].[0-30], [Measures].[31-60], [Measures].[61-90], [Measures].[90-120], [Measures].[>120]} on 0,
 {
 [Customer].[Name].[Name].Allmembers
 } on 1
from [My Cube]