joliver388
2 years agoNew Contributor III
Complex Expression on Matrix Data Load
I have a complex expression on the amount field in a data source used to convert any non-local currencies to the local currency (see below). That complex expression currently runs on tabular data with the time period (CurTime) I reference to pull the FX rate in one field. I am now wanting to have this same complex expression used on a Matrix data source with time across 24 fields. Any thoughts on how this could be done? Is there a Column Number api I could use to define CurTime?
'This is to look to see if the entity is a non local USD entity and convert the USD data to Local
Dim fields As List(Of String) = StringHelper.Splitstring(args.Line,",")
Dim curEntity As String = fields(2)
Dim UKEntityDim As OneStream.Shared.Wcf.Dim = BRApi.Finance.Dim.GetDim(si, "iFinDept")
Dim UKEntityDimTypeID As Integer = UKEntityDim.DimPk.DimTypeId
Dim CurEntityID As Integer = BRApi.Finance.Members.GetMemberId(si,UKEntityDimTypeID , curEntity)
Dim CurEntityLocCur As String = BRApi.Finance.Entity.GetLocalCurrency(Si, CurEntityID).Name
If CurEntityLocCur.XFEqualsIgnoreCase("USD") Then
Return Args.Value
Else
'Get Workflow Scenario ID
Dim wfScenarioName As String = ScenarioDimHelper.GetNameFromID(si, si.WorkflowClusterPk.ScenarioKey)
Dim wfScenarioId As Integer = ScenarioDimHelper.GetIdFromName(si, wfScenarioName)
'Pull the Current Time that we are looking at
Dim CurTime As String = fields(1)
'Brapi.ErrorLog.LogMessage(si, args.line.tostring)
Dim FxRateType As String = BRApi.Finance.Scenario.GetFxRateTypeForRevenueExpense(si, wfScenarioId).Name
Dim FxRatePkUsingNames As New FxRatePkUsingNames
FxRatePkUsingNames.DestCurrency = "USD"
FxRatePkUsingNames.SourceCurrency = CurEntityLocCur
FxRatePkUsingNames.Time = CurTime
FxRatePkUsingNames.FxRateType = FxRateType
Dim FxRate As Decimal = BRApi.Finance.Data.GetStoredFxRate(si, FxRatePkUsingNames).Amount
If FxRate <> 0 Then
Return args.Value / FxRate
End If
End If