Forum Discussion
Marcello
3 years agoContributor
api.Data.SetDataBuffer in increment mode
Hi all,
we have a databuffer with values to be cumulated in a specifi destination intersection.
The issue we have is that api.Data.SetDataBuffer always wirte the last value.
Is there a standard...
- 3 years ago
Hi Giacomo,
we had a call with a Onestream consultant
The final outcome is that we agreed that the best way to handle cumulation is to use the "evergreen" api.Data.GetDataCell and "api.Data.Calculate" (while looping records in the databuffer).
This give us 2 advantages:
- we can instruct the calculation with element names rather than the IDs
- we can debug the calculation line by line
Thanks a lot for the help.
Marcello
Marcello
3 years agoContributor
Hi Giacomo,
thanks for the clarification but I don't think this can work.
We need to cumulate in the destination intersection, not the databuffer cell.
We are looking for the "accumulateIfCellAlreadyExists" to be applied to the SetDataBuffer, not the setCell.
Because every time we loop on a new record of databuffer the cumulated value in the destination cell has gone away.
Thanks,
Marcello
JackLacava
OneStream Employee
3 years agoI'm slightly confused by what you mean "in the destination intersection, not the databuffer cell" - cell and intersection are equivalent terms to indicate a single number. Buffers contain cells.
Hopefully this clarifies the two approaches:
Dim destInfo As ExpressionDestinationInfo = api.Data.GetExpressionDestinationInfo("A#TargetAccount:O#Import")
Dim bufOrig As DataBuffer = api.Data.GetDataBufferUsingFormula("A#SourceAccount:O#Import")
Dim bufNew As DataBuffer = api.Data.GetDataBufferUsingFormula("A#SomeOtherAccount:O#Forms")
' sum up all cells - simple, fast, the best
api.Data.SetDataBuffer((bufOrig + bufNew), destInfo)
' or loop by record - slower, might be more flexible
' for each cell in the new set...
For Each newCell As DataBufferCell In bufNew.DataBufferCells.Values
'... copy the cell ...
Dim resultCell As New DataBufferCell(newCell)
' ... add it to the existing buffer, accumulating ...
bufOrig.SetCell(si, resultCell, True)
Next
'... then save back the original buffer, now with accumulated values
api.Data.SetDataBuffer(bufOrig, destInfo)
Note that Target and Source account don't have to be different, they can be the same.
Related Content
- 2 years ago
- 4 years ago
- 1 month ago