Cube View Column that contains aggregate of the last 12 months
Hi all,
I'm trying to create a Cube View with a single column that aggregates data for the past 12 months, rather than showing each month separately.
Instead of this:
Month | May 2024 | Jun 2024 | Jul 2024 | Aug 2024 | Sep 2024 | Oct 2024 | Nov 2024 | Dec 2024 | Jan 2025 | Feb 2025 | Mar 2025 | Apr 2025 |
Sales | 10 | 20 | 30 | 10 | 20 | 30 | 10 | 20 | 30 | 10 | 20 | 30 |
I'd like this:
Time Period | Last 12 Months |
Aggregate Sales | 240 |
To do this, I created an XFBR business rule that returns a time range like
T#2024M5:T#2025M4
Here’s the relevant part of my XFBR:
If args.FunctionName.XFEqualsIgnoreCase("Trailing12Months") Then
Dim baseYear As Integer = args.NameValuePairs("year")
Dim baseMonth As Integer = args.NameValuePairs("month")
Dim endDate As New DateTime(baseYear, baseMonth, 1)
Dim startDate As DateTime = endDate.AddMonths(-11)
Dim startMember As String = String.Format("T#{0}M{1}", startDate.Year, startDate.Month)
Dim endMember As String = String.Format("T#{0}M{1}", endDate.Year, endDate.Month)
Return String.Format("{0}:{1}", startMember, endMember)
End If
I confirmed the XFBR returns the correct string, and I’m using it in the Member Filter of the Time column in the Cube View. However, the Cube View only shows data for the last month instead of aggregating all 12 months.
My Question:
Is T#YYYYMn:T#YYYYMn a valid range for Cube View member filters? Is there a way to achieve what I'm trying to do?
Thanks in advance for any advice!
Have you tried the out-of-the-box V# member that does a trailing 12 month total for you?
V#Trailing12MonthTotal is a dynamic view member calculation that does this already.