Calc’d A# with ‘VaryByTimeId ’
SOURCE: ONESTREAM CHAMPIONS
Hi all,
I’m largely self taught with vb, but have hit a wall with this, and thought I’d share here rather than ask the OS helpdesk, as it seems to be something that could prove useful to others. I’m trying to write a calculated account which refers an entity Text field, using multiple values varied by time in the calculation.
We set a value for Cost of production for certain categories of products (spares and accessories) by % on a varied by time basis on the entity. This can vary from year to year (in theory could vary in year)
Specifically, I want to find the value that is valid at prior year end and subtract the current value from that. The value may have been set earlier M12 may conain no value but M8 of the same prior year does, for example.
I’ve introduced a loop to try and go back through periods until a value is found, but can’t see whether that’s working as I’m still getting an error message.
Dim PeriodPOV As Integer = api.POV.Time.MemberId Dim PriorPeriod As Integer = api.Time.GetLastPeriodInPriorYear() Dim dCurrValue As Decimal = api.Entity.Text(EntityID,2,,PeriodPOV) Dim dPriorValue As Decimal = api.Entity.Text(EntityID,2,,PriorPeriod) Dim ValueChk As Boolean = True Dim PriorValueChk As Integer = dPriorDDU Dim PriorPeriodChk As Integer = ""
Do While ValueChk = True
PriorPeriodChk = api.Time.GetPriorPeriod(PriorPeriod)
PriorChk = api.Entity.Text(EntityID,2,PriorPeriodChk)
If PriorChk = 0 Then
ValueChk = False
End If
Loop
api.data.Calculate("(A#BALSHEETACCOUNT:U7#SOURCE_ADJ:UDX#" & _
"= (A#MEMOACCOUNT:U7#SOURCE_TOP:UDX# * 1 - ( 1 / (1 + " & dCurrValue & “))” & _
"- (A#MEMOACCOUNT:U7#SOURCE_TOP:UDX# * 1 - (1 / (1 + " & dPriorValue & “)))”)
Error message is that “Conversion from string “” to type ‘Integer’ is not valid”. Is the issue in the format of dCurrValue and dPriorValue and that I’m pulling those through as strings when they should be integers/decimals? Or am I missing something else?
Many thanks in advance.
Barry