benmac360
9 months agoNew Contributor III
Pass Results from Business Rule into UD8 Formula
Hi - I have a dashboard XFBR business rule that calculates totals for members with a specific text value in a cube view. The rule is working as designed, and I have a couple GetDataCell functions in separate columns that reference these totals. However, I also have a UD8 member for variance analysis purposes that need the totals to determine whether or not a value exceeded a threshold - how do I pass what my business rule calculates into my UD8 formula?
Here's the business rule for reference:
If args.FunctionName.XFEqualsIgnoreCase("CVMath") Then
'Math function used in CV
Dim MathFunction As String = "GetDataCell("
'Suffix for GetDataCell function
Dim Suffix As String = "):Name(Total)"
'Get ColNames to use in Math Function
Dim ColNametoSum As String = args.NameValuePairs.XFGetValue("ColName")
'Prefix
Dim ColMath As String = "CVC(" & ColNametoSum & ","
'Get cube view member filter
Dim cvMemberFilter As String = args.NameValuePairs.XFGetValue("MemberFilter")
BRApi.ErrorLog.LogMessage(si, cvMemberFilter)
'This is an entity driven member filter
If cvMemberFilter.StartsWith("E#", stringcomparison.CurrentCultureIgnoreCase) Or cvMemberFilter.StartsWith("E#[", stringcomparison.CurrentCultureIgnoreCase) Then
'Get the entity dimension name used in the CV
Dim EntityDimName As String = args.NameValuePairs.XFGetValue("EntityDim")
'Get count of members returned
Dim memberCount As Integer =BRApi.Finance.Metadata.GetMembersUsingFilter(si, EntityDimName, cvMemberFilter, False, Nothing, Nothing).Count
Dim finalList As New List(Of String)
For i As Integer = 1 To memberCount
Dim cvc As String = ColMath & i.ToString & ")"
finalList.Add(cvc)
Next
Return MathFunction & String.Join("+", finalList.ToArray()) & Suffix
End If
End If
Here's the UD8 formula:
Dim myWorkflowUnitPk As WorkflowUnitPk = BRApi.Workflow.General.GetWorkflowUnitPk(si)
Dim wfTime As String = BRApi.Finance.Time.GetNameFromId(si, myWorkflowUnitPk.TimeKey)
'Take the variance between CY Actuals and PY Actuals at CY Rates for a given time period
Dim OnePctAmount As Decimal = api.data.GetDataCell("(S#Actual:T#[" & wfTime & "]:V#QTD:u8#none)*.01").CellAmount
Dim OnePctAmount_abs As Decimal = Math.Abs(OnePctAmount)
''Return VarAmount
If OnePctAmount_abs > 30000000 Then
Return "Y"
Else
Return ""
End If