MDX - Cumulative Sum Not working when selecting multiple dates

拜拜、爱过 提交于 2019-12-24 21:16:56

问题


I've build an MDX calculated member that returns the Cumulative Sales over time. - the query returns correct results if no filters applied or the user filters with 1 month

my problem is that when the user selects multiple months the query returns the cumulative for the whole year

here is what i wrote using Dynamic Set, Calculated Member and Scope:

Dynamic Set:

PeriodToDate = EXISTING PeriodsToDate([Date].[Calendar - YQMD].[Year],[Date].[Calendar - YQMD].CurrentMember)

Calculated Member:

( PeriodsToDate([Date].[Calendar - YQMD].[Year],[Date].[Calendar - YQMD].CurrentMember) ,[Measures].[Sales Amount - Foreign] )

Scope:

Scope ( [Date].[Calendar - YQMD].[Year], [Measures].[Sales Amount - Foreign] )

This = Aggregate([PeriodToDate],[Measures].[Sales Amount - Foreign])

End Scope


回答1:


Try this:

Create Dynamic Set CURRENTCUBE.SelectedMonths as [Date].[Calendar - YQMD].[Month].Members;

Scope ( [Date].[Calendar - YQMD].[Year], [Measures].[Sales Amount - Foreign] );
    This = Aggregate(PeriodsToDate([Date].[Calendar - YQMD].[Year], Tail(Existing SelectedMonths,1).Item(0).Item(0)));
End Scope;


来源:https://stackoverflow.com/questions/59157464/mdx-cumulative-sum-not-working-when-selecting-multiple-dates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!