09-29-2022 03:01 PM - last edited on 09-30-2022 05:58 AM by JackLacava
I have a dynamically calculated member formula. It is returning the wrong value for each Quarter, it should be the sum of the M1+M2+M2 ($1,614,441.60) and not be recalculated ($1,649,190.40).
Is there a member property or formula examples that can help me resolve this issue. Thanks.
Sample calc
Drill down formula
I tried setting a different formula on the quarter, but I get the error message “The Dynamic Calc Member Formula is recursively calling itself:.
Thanks,
Solved! Go to Solution.
09-30-2022 11:10 AM
Mr Thompson!
At first I'm like "what kind of accounting sorcery is Randy performing wanting to add M1 + M2 + M2 for Q1??" but then looked at your screenshot and figured you made a typo 🤣
I honestly wouldn't bother to set formulas on Varying Member Properties by Time... your approach requires that you setup formulas on all quarters, halfs and full year which is cumbersome.
What I would actually do is revisit the formulas on the dynamic accounts such as Base_Payroll_Ind_Non_Exempt and add a condition to run the calculation only if the Time POV is on a month. Here's an example where I setup a dynamic account and perform a recursive call on itself to accumulate base values:
This screenshots are the results from above:
09-30-2022 11:25 AM
What you could do is detect whether you are dealing with a base Time period or not, and calculate things differently in the various cases. What follows is an example of the approach:
If api.Pov.Time.Name.XFContainsIgnoreCase("M") Then
Return api.data.getDataCell(".... your normal formula ...")
Else
Return api.Data.GetDataCell("T#2021M1 + T#2021M2 + T#2021M3")
End If
Obviously you'll want to make the "else" part more dynamic (checking if quarters, half-years, or years, and determine which periods to use - have a look at the calls in api.Time ...) but hopefully you get what the work is.
As a side note, if you need to do this sort of aggregation, it might be an indication that the value really should be stored rather than dynamic. Dynamics don't aggregate naturally (as you've just discovered), they are mostly meant for quick ratios and stuff like that.
10-03-2022 04:25 AM - edited 10-03-2022 05:35 AM
Cool stuff Randy! Just a top tip: instead of concatenation, it might be a bit more performant to use string interpolation, e.g.:
Return api.Data.GetDataCell($"T#{wfYear}M1 + T#{wfYear}M2 + T#{wfYear}M3")
Note the string is preceded by $ and the variables are referenced in the string surrounded by curly braces.
Note this is not a feature of GetDataCell, but a generic string-manipulation technique in recent VB.Net.
10-03-2022 10:48 AM
Of course! You're OG.
Just one small note to consider in your formula calc. I think you may need to include :V#Periodic within your formula to ensure you're not calculating using V#YTD or any other view member POV selection. You want to ensure that you're getting consistent results to your calculated account regardless of the View POV selection.
09-30-2022 05:06 AM
Hi Randy
1) Drilldown formula is irrelevant for calc purposes, you can ignore that.
2) Varying a formula by time just means "from this period onwards, use this formula". So the formula you entered would be called to calculate M1, which in turn would ask for the value of M1... hence getting cyclical.
My experience on formulas is limited, but I would probably have to look at the actual formula to make a guess on why this is happening, but it might also be things like adjustments... A more experienced consultant might have a better idea.
09-30-2022 09:57 AM
Here is the formula:
I tried changing the account type for each accounts called in the formula from balance recurring to nonfinancial to expense to flow. None of these changes impacted the calculated quarterly value.
09-30-2022 11:25 AM
What you could do is detect whether you are dealing with a base Time period or not, and calculate things differently in the various cases. What follows is an example of the approach:
If api.Pov.Time.Name.XFContainsIgnoreCase("M") Then
Return api.data.getDataCell(".... your normal formula ...")
Else
Return api.Data.GetDataCell("T#2021M1 + T#2021M2 + T#2021M3")
End If
Obviously you'll want to make the "else" part more dynamic (checking if quarters, half-years, or years, and determine which periods to use - have a look at the calls in api.Time ...) but hopefully you get what the work is.
As a side note, if you need to do this sort of aggregation, it might be an indication that the value really should be stored rather than dynamic. Dynamics don't aggregate naturally (as you've just discovered), they are mostly meant for quick ratios and stuff like that.
10-01-2022 10:57 AM
Thanks Jack, here is what I used. Cosimo's solution works as well except my client has a weekly calendar set up for future use, so the GetBaseMembers was returning empty weeks and not the monthly calculated value.
10-03-2022 04:25 AM - edited 10-03-2022 05:35 AM
Cool stuff Randy! Just a top tip: instead of concatenation, it might be a bit more performant to use string interpolation, e.g.:
Return api.Data.GetDataCell($"T#{wfYear}M1 + T#{wfYear}M2 + T#{wfYear}M3")
Note the string is preceded by $ and the variables are referenced in the string surrounded by curly braces.
Note this is not a feature of GetDataCell, but a generic string-manipulation technique in recent VB.Net.
10-03-2022 09:37 AM
Thanks Jack.
09-30-2022 11:10 AM
Mr Thompson!
At first I'm like "what kind of accounting sorcery is Randy performing wanting to add M1 + M2 + M2 for Q1??" but then looked at your screenshot and figured you made a typo 🤣
I honestly wouldn't bother to set formulas on Varying Member Properties by Time... your approach requires that you setup formulas on all quarters, halfs and full year which is cumbersome.
What I would actually do is revisit the formulas on the dynamic accounts such as Base_Payroll_Ind_Non_Exempt and add a condition to run the calculation only if the Time POV is on a month. Here's an example where I setup a dynamic account and perform a recursive call on itself to accumulate base values:
This screenshots are the results from above:
10-01-2022 10:50 AM
Thanks Cosimo, still bailing me out for the last 25 years.
10-03-2022 10:48 AM
Of course! You're OG.
Just one small note to consider in your formula calc. I think you may need to include :V#Periodic within your formula to ensure you're not calculating using V#YTD or any other view member POV selection. You want to ensure that you're getting consistent results to your calculated account regardless of the View POV selection.
10-03-2022 10:56 AM
Will do. Thanks again for your sage advice.