The OneStream Community is temporarily frozen until June 29th due to the ongoing maintenance. Please read the blog post here to learn more.
Forum Discussion
Kamila
2 years agoContributor
GetDataBuffer takes too much time to process
Dear Team,
I'm trying to understand what caused the low performance of my code. I see that it's because of many loops, but I'm wondering if there's any possible way to fix it:
Dim ResultDataB...
RobbSalzmann
2 years agoValued Contributor II
Databuffers are made to be efficient in processing all the cells in one collection(the buffer). Create one databuffer will all your accounts and ICs in it instead of looping over the accounts and ICs one at a time.
This should get you close:
Dim ResultDataBuffer As DataBuffer = New DataBuffer()
Dim sAccounts As List(Of String) = New List(Of String) From {
"1711050",
"2742020",
"1712020",
"2745060",
"1346010",
"2413010",
"1742050",
"2716050",
"1745010",
"2713010",
"3221010",
"3221020",
"3221030",
"4451010",
"4451020",
"4451030",
"1722060",
"2741030",
"4541070",
"4321020",
"4541010",
"4541020",
"3222010",
"4452010",
"4541030",
"4541040",
"4541050",
"4541060",
"5111010",
"5111020"}
Dim accountsFilter As String = String.Join(",", sAccounts.Select(Function(account) $"A#{account}"))
Dim iCsFilter As String = String.Join(",", icMembers.Select(Function(ic) $"I#{ic}"))
Dim DestinationInfo As ExpressionDestinationInfo = api.Data.GetExpressionDestinationInfo($"Filtermembers(O#Forms:UD1#None:UD2#None,[{accountsFilter}],[I#Top_member].Base)")
Dim StartingDataBuffer As DataBuffer = api.Data.GetDataBufferUsingFormula($"RemoveZeros(O#Forms:UD1#None:UD2#None,[{accountsFilter}],[I#Top_member].Base))")
For Each sourceCell As DataBufferCell In StartingDataBuffer.DataBufferCells.Values
Dim resultCell As New DataBufferCell(sourceCell)
resultcell.SetOrigin(api,"Forms")
resultcell.SetIC(api,Ic.Name)
resultcell.SetAccount(api,Acc)
resultcell.CellAmount = 0
resultCell.CellStatus = DataCellStatus.CreateDataCellStatus(True, False)
'Set target member
ResultDataBuffer.SetCell(si,resultcell)
Next
'Save the Data Buffer using Result Data Buffer and Destination Info
api.Data.SetDataBuffer(ResultDataBuffer,DestinationInfo)
Related Content
- 3 years ago
- 15 days ago
- 2 years ago