I am writing the Business rule in Revenue % account dimension, Revenue % = X / PY Y. My PY can be based on POV. For example, if user can select current year as FY2024 then PY is FY2023 or If user ch...
Imports System
Imports System.Collections.Generic
Imports System.Data
Imports System.Data.Common
Imports System.Globalization
Imports System.IO
Imports System.Linq
Imports Microsoft.VisualBasic
Imports OneStream.Finance.Database
Imports OneStream.Finance.Engine
Imports OneStream.Shared.Common
Imports OneStream.Shared.Database
Imports OneStream.Shared.Engine
Imports OneStream.Shared.Wcf
Imports OneStream.Stage.Database
Imports OneStream.Stage.Engine
Namespace OneStream.BusinessRule.DashboardStringFunction.SampleTimeRule
Public Class MainClass
Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As DashboardStringFunctionArgs) As Object
Try
If (args.FunctionName.XFEqualsIgnoreCase("GetPriorTimeDyn")) Then
'Use name/value pair to store the POV time in the business rule
Dim povTimeName As String = args.NameValuePairs.XFGetValue("PovTimeName")
'Extract the current and prior year names from the selected POV time
Dim povYearName As String = TimeDimHelper.GetYearFromId(TimeDimHelper.GetIdFromName("povTime"))
Dim priorYearName As String = TimeDimHelper.GetYearFromId(TimeDimHelper.GetPriorYearPeriodId(TimeDimHelper.GetIdFromName(povTimeName)))
'Create empty string to store return time
Dim returnTimeName As String = String.Empty
If povTimeName.Length = 4 'Year
'Return the same month for the prior year
returnTimeName = priorYearName
Else If povTimeName.Substring(4, 1).XFEqualsIgnoreCase("M") 'Months
'Extract current month from POV time and convert to a string
Dim povMonthNum As String = TimeDimHelper.GetSubComponentsFromName(povTimeName).Month.XFToString
'Return the same month for the prior year
returnTimeName = String.Concat(priorYearName,"M", povMonthNum)
Else If povTimeName.Substring(4, 1).XFEqualsIgnoreCase("Q") 'Quarters
'Extract current quarter from POV time and convert to a string
Dim povQuarterNum As String = TimeDimHelper.GetSubComponentsFromName(povTimeName).Quarter.XFToString
'Return the same month for the prior year
returnTimeName = String.Concat(priorYearName,"Q", povQuarterNum)
Else If povTimeName.Substring(4, 1).XFEqualsIgnoreCase("H") 'Half Year
'Extract current quarter from POV time and convert to a string
Dim povHalfYearNum As String = TimeDimHelper.GetSubComponentsFromName(povTimeName).HalfYear.XFToString
'Return the same month for the prior year
returnTimeName = String.Concat(priorYearName,"H", povHalfYearNum)
End If
Return returnTimeName
End If
Return Nothing
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End Function
End Class
End Namespace
This XFBR will dynamically call the corresponding prior year equivalent. You should be able to use a name/value pair to similarly insert the relevant account into the calculation. There is likely a simpler way to accomplish what you are looking for, but this should work for most cases.
To call the XFBR from a member filter, use the following: T#|POVTime|, T#XFBR(SampleTimeRule, GetPriorTimeDyn, povTimeName=|POVTime|) - you can adjust this to use parameters as needed.