Marco
21 hours agoContributor II
How do I clean a scenario before copying data from another scenario? in the member formula.
Hi Everyone.
I want to copy the information from one scenario to another. Currently, I’m using the member formula of the target scenario to transfer the data. However, I first apply a calculate to set the values to zero, followed by a clecarcalculateddata to properly remove the existing information. The issue is that after this step, the copy process doesn’t execute, and the scenario remains with zero values. My code is as follows:
api.Data.calculate("S#FORECAST_" & monthNumber & "_AT_CY_BUDGET_RATE = 0*(S#FORECAST_" & monthNumber & "_AT_CY_BUDGET_RATE)",True)
api.Data.ClearCalculatedData("S#FORECAST_" & monthNumber & "_AT_CY_BUDGET_RATE",True,True,True,True)
Dim destinationInfo As ExpressionDestinationInfo = api.Data.GetExpressionDestinationInfo("S#FORECAST_" & monthNumber & "_AT_CY_BUDGET_RATE")
'' Create new Databuffer for the results
Dim resultDataBuffer As New DataBuffer
'Base Entity at Local
If Not api.Entity.HasChildren And api.Cons.IsLocalCurrencyForEntity() Then
BRapi.ErrorLog.LogMessage(si,"Validate 1")
' Get Databuffer from the account and scenario
Dim sourceDataBuffer As DataBuffer = api.data.GetDataBufferUsingFormula("RemoveZeros(FilterMembers(S#[Forecast " & TimeName & "],[A#Root.Base]))", , False)
' Verificar si hay celdas con datos
If sourceDataBuffer.DataBufferCells.Count > 0 Then
BRapi.ErrorLog.LogMessage(si,"Validate 2")
For Each sourceCell As DataBufferCell In sourceDataBuffer.DataBufferCells.Values
If (Not sourceCell.CellStatus.IsNoData) And (sourceCell.CellAmount <> 0.0) Then
BRapi.ErrorLog.LogMessage(si,"Validate 3")
Dim resultCell As New DataBufferCell(sourceCell)
resultCell.DataBufferCellPk.OriginId = DimConstants.Import
resultDataBuffer.SetCell(si, resultCell, True)
End If
Next
api.Data.SetDataBuffer(resultDataBuffer, destinationInfo,,,,,,,,,,,,,False)
End If
End If
I would appreciate your help in understanding why the values are not being copied. The process is executed when I consolidate the information.