06-28-2022 02:21 AM - last edited on 05-02-2023 09:54 AM by JackLacava
Hi,
Can anybody help with this error? what we need to check for this in business rule.
06-28-2022 02:28 AM
Hi, the issue is that your business rule CG_StatisticalCalcs tries to put a value in a parameter/ datatable/ object where the type of Decimal is expected. However the number that is processes is too big to fit in the Decimal specifications.
Decimal is already very big 28 to 29 significant digits, so i would suggest investigating your data where this very large number is comming from.
06-28-2022 09:59 AM
With VB.net, it is possible to calculate with larger number than what the datatype decimal allows you to do, by using floating point data types (single and double). Of cause, to store it back to Onestream, it needs to fit to a decimal datatype. But if only the intermediate results are to big something like this will work:
Dim scriptS As String = "..."
Dim scriptT As String = "..."
Dim number1 As Double = api.data.GetDataCell(scriptS).CellAmount 'i.e. 1000000000000000000
Dim number2 As Double = api.data.GetDataCell(scriptS).CellAmount 'i.e. 1000000000000000000
Dim number3 As Double = api.data.GetDataCell(scriptS).CellAmount 'i.e. 1000000000000000000
Dim result As Double = number1 * number2 / number3
Dim resultDec As Decimal = result
api.Data.SetDataCell(scriptT, resultDec, False)
So, if your calculation only fails, because it has problems with intermediate results (and with statistics this is possible), but the final result are in the range of a decimal, you can calculate it like this.
Be aware, like in Excel, scientific notification looses precision the larger a number gets, so it might not be 100% correct (That's the reason, we are using decimals instead of floats).
06-30-2022 08:13 AM
Hi, try to check that the variable which stores the value in your business rule is declared as decimal.