【发布时间】:2023-03-21 22:36:02
【问题描述】:
我需要有计算成员来计算基于 Dim Date 的运行总数 这应该适用于报告中过滤的所有日期。 大多数解决方案从 Dim Date 或 Null 中的第一个日期计算到当前成员,但我需要从过滤到当前成员的第一个日期计算并排除它们不在过滤器中的日期
【问题讨论】:
标签: ssas mdx cumulative-sum
我需要有计算成员来计算基于 Dim Date 的运行总数 这应该适用于报告中过滤的所有日期。 大多数解决方案从 Dim Date 或 Null 中的第一个日期计算到当前成员,但我需要从过滤到当前成员的第一个日期计算并排除它们不在过滤器中的日期
【问题讨论】:
标签: ssas mdx cumulative-sum
试试这个:
//capture the dates selected in the where clause of the query
CREATE DYNAMIC SET CURRENTCUBE.SelectedDates as
[Dim Date].[Date].[Date].Members;
CREATE MEMBER CURRENTCUBE.[Measures].[Cumulative Sale Price] as
Sum(
{
SelectedDates.Item(0).Item(0)
:
Tail(Existing [Dim Date].[Date].[Date].Members, 1).Item(0).Item(0) //capture the last date present in the Filter context for this cell
},
[Measures].[Sale Price]
);
CREATE MEMBER CURRENTCUBE.[Measures].[Cumulative Sale Price with Skips] as
Sum(
Exists(
SelectedDates,
{
SelectedDates.Item(0).Item(0)
:
Tail(Existing [Dim Date].[Date].[Date].Members, 1).Item(0).Item(0) //capture the last date present in the Filter context for this cell
}
),
[Measures].[Sale Price]
);
【讨论】: