Forum Discussion

mireles's avatar
mireles
New Contributor III
4 days ago
Solved

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:

MonthMay 2024Jun 2024Jul 2024Aug 2024Sep 2024Oct 2024Nov 2024Dec 2024Jan 2025Feb 2025Mar 2025Apr 2025
Sales102030102030102030102030

 

I'd like this:

Time PeriodLast 12 Months
Aggregate Sales240

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.

     

2 Replies

  • T_Kress's avatar
    T_Kress
    Valued Contributor

    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.