我试图在特定时间点获取政策的最后状态。例如,我们在 sql server 表中存储了以下信息:
TrackerId,policyNumber,statusDescription,YearMonthDay,YearMonth
1 a active 2000-01-01 2000-01
2 b active 2000-01-02 2000-01
3 c active 2000-01-03 2000-01
4 d active 2000-01-04 2000-01
5 e active 2000-01-05 2000-01
6 b suspended 2000-02-01 2000-02
7 c cancelled 2000-02-02 2000-02
8 b reinstated 2000-03-01 2000-03
9 e cancelled 2000-03-02 2000-03
10 f active 2000-04-01 2000-04
11 g active 2000-04-02 2000-04
从上面,我试图在 mdx 中以以下格式获取结果
date,openingBalance,new business,reinstated,lapse,cancelled/suspended,closing balance
2000-01 0 5 0 0 0 5
2000-02 5 0 0 0 2 3
2000-03 3 0 1 0 0 4
2000-04 4 2 0 0 1 5
“新业务”是当月新的政策,即“有效”。这同样适用于“失效”、“取消”和“暂停”状态。
我有以下尺寸: Status
, Time
, Policy
.
计算“新业务”、“恢复”、“失效”和“取消/暂停”很简单,如下所示:
member [Measures].[New Business] as
([Status].[Status].&[1],[Measures].[Policy Count])
member [Measures].[Suspended] as
([Status].[Status].&[2],[Measures].[Policy Count])
member [Measures].[Cancelled] as
([Status].[Status].&[3],[Measures].[Policy Count])
member [Measures].[Suspended+Cancelled] as
([Measures].[Suspended]+[Measures].[Cancelled])
member [Measures].[Reisntated] as
([Status].[Status].&[4],[Measures].[Policy Count])
member [Measures].[Lapsed] as
([Status].[Status].&[5],[Measures].[Policy Count])
我的问题是为“期末余额”和“期初余额”制定计算成员。“收支平衡”背后的逻辑是它应该给我当时所有的有效政策。例如,在“2000-02”,policyNumber [a]、[d]、[e] 处于活动状态,而 [b] 和 [c] 分别被暂停和取消。所以我的期末余额应该是“3”。
任何帮助,将不胜感激。