Krishna
2 years agoValued Contributor
Data Buffer
Hi - I am trying to execute the below code but it is not taking the prior month actual data. Could you please let me know what am doing wrong? It is copying only the current month. Dim S...
- 2 years ago
That's better. Note that you don't even need to assign buffers to variables for simple math, you can just do:
Dim buf1 as DataBuffer = api.data.GetDataBufferUsingFormula(...) Dim buf2 as DataBuffer = api.data.GetDataBufferUsingFormula(...) Dim result as DataBuffer = buf1 + buf2 api.Data.SetDataBuffer(si, result, targetDestExpressionInfo)
As for the last bit: you know how, in your first code, you retrieved a buffer then looped through its cells? You can simply retrieve two buffers, then manipulate their cells directly. A buffer is effectively a dictionary, where keys are DataBufferCellPK and values are DataBufferCell; so you can get the PK of cells from buf1 and look up if there is an equivalent one with the same PK in buf2. Because this would be done in memory, rather than retrieving from db every time (which is what GetDataCell would do), it's still fast enough (even though working at the buffer level is likely to be faster).