我可以通过使用下面的逻辑设置老化存储桶来创建老化存储桶,尽管查询运行存储桶都会返回空白。我最初使用了一些使用lag
的逻辑,但发现lag
计算的是成员级别而不是实际天数。我在这里缺少什么?
WITH
member [0-30] as ( IIF (Datediff("d", [TXN].[Age Date], STRTOMEMBER(@ToDOSDate,CONSTRAINED) ) >=0 AND Datediff("d", [TXN].[Age Date], STRTOMEMBER(@ToDOSDate,CONSTRAINED) ) <= 30
, [measures].[charge_amount] , 0)
)
member [31-60] as ( IIF(Datediff('d', [TXN].[Age Date], STRTOMEMBER(@ToDOSDate,CONSTRAINED) ) >=31 AND Datediff('d', [TXN].[Age Date], STRTOMEMBER(@ToDOSDate,CONSTRAINED) ) <= 60
,[measures].[charge_amount], 0 )
)
member [61-90] as ( IIF(Datediff("d", [TXN].[Age Date], STRTOMEMBER(@ToDOSDate,CONSTRAINED) ) >=61 AND Datediff("d", [TXN].[Age Date], STRTOMEMBER(@ToDOSDate,CONSTRAINED) ) <= 90
,[measures].[charge_amount], 0 )
)
member [91-120] as ( IIF(Datediff("d", [TXN].[Age Date], STRTOMEMBER(@ToDOSDate,CONSTRAINED) ) >=91 AND Datediff("d", [TXN].[Age Date], STRTOMEMBER(@ToDOSDate,CONSTRAINED) ) <= 120
,[measures].[charge_amount], 0 )
)
member [120+] as ( IIF(Datediff("d", [TXN].Age Date], STRTOMEMBER(@ToDOSDate,CONSTRAINED) ) >= 120
,[measures].[ charge_amount], 0 )
)
答案 0 :(得分:0)
我假设:
[TXN].[Age Date]
子句中有SELECT
ON ROWS。 @ToDOSDate
是正确的,并且您已经完全测试了它在进入STRTOMEMBER(@ToDOSDate,CONSTRAINED)
时是否正常工作。 Datediff
是一个vba函数,需要 date 类型的数据作为它的参数 - 你输入的是成员类型的数据。
我要做的另一个假设是,层次结构Name
成员的[TXN].[Age Date]
属性的格式被设置为被解释为日期。然后,您可以执行以下操作:
WITH
MEMBER [Measures].[0-30] AS
IIF (
Datediff(
"d"
,[TXN].[Age Date].CURRENTMEMBER.NAME
,STRTOMEMBER(@ToDOSDate,CONSTRAINED).NAME
) >=0
AND
Datediff(
"d"
,[TXN].[Age Date].CURRENTMEMBER.NAME
,STRTOMEMBER(@ToDOSDate,CONSTRAINED).NAME
) <= 30
, [measures].[charge_amount]
, NULL)