Finance Business Rule Data.Calculate format

jzachar
New Contributor

I'm struggling to understand how exactly to calculate what I need, a confirmation of direction and a little guidance would be great!  I need to calculate an account value (Factored account)  from a Driver account * a Percent account.  The Driver account data contains many different dimension attributes (product, region, customer, etc).  The percent account is at the 'None' member of those different dimensions.  The calculated Factor accounts need to be at the same level (members) as the Driver account.  I'm sure (i think, lol) I need to use the data.calculate, but I'm struggling on the syntax of the function to calculate using data at 2 different account POVs, and the results residing at the same level as the Driver account.  Whether I'll need to create data buffers and manipulate / save or simple filters within the data.calculate.  I do have multiple Drivers for some Factored account (i.e F1 = (D1*Pct) + (D2*Pct) + (D3*Pct)), and multiple Factor accounts using the same Driver (i.e F1 = (D1*Pct) , F2= (D1*Pct)). A simple road map would be great, anything more would be even better.  I'd like to first get a simple example working (i.e F1 = (D1*Pct) and expand it once it works and I understand the syntax needed. Thanks in advance

2 REPLIES 2

akatsman
New Contributor III

Hi Jzachar,

This sounds like an ideal situation to use a data buffer. It will allow you to run through all the different dimensions of your driver account while using a get data cell for the percent account. This will allow you to do the math on each source cell of the data buffer while using the specific percent. Since you want to use the same dimensionality as the driver, utilizing the source data buffer information will be useful. You also have the ability to set output account to the factor account it should go to.

For the factor accounts that use multiple percentages, you can use if statements while looping through the data buffer to calculate that information as needed.

Thanks,
AJ

rhankey
New Contributor III

I can think of at least two options to accomplish your need using the api.Data.Calculate() function:

api.Data.Calculate("DestinationPath = UnbalancedMultiply(FactorPath,DriverPath,UnbalancedPath)")

api.Data.Calculate("DestinationPath = Eval2(DriverPath,FactorPath)",AddessOf OnEvalBufferHandler)

Private Sub OnEvalBufferHandler(ByVal api As FinanceRulesApi, ByVal evalName As String, ByVal eventArgs As EvalDataBufferEventArgs)

'Cycle through DataBuffer1, and lookup rate from DataBuffer1 using a key that sets dims to DimConstants.None as applicable, perform multiply and write out results.

End Sub

UnbalancedPath in the first example provides the dimensionality to use with FactorPath for the dims that are missing from the DriverPath.

I use the Unbalanced() functions occasionally, but I normally use an OnEval hander, as it is far more flexible when the requirements take a left turn after the fact.  And I find it a whole lot easier to debug the OnEval method, whereas the Unbalanced() option saves a few lines of code but is a bit of a black-box when anything goes wrong.