我想在特定时间点获取政策的最后状态。例如,我们在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”。
任何帮助都将不胜感激。