Dynamically Calculate Q1 total as sum of children
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,
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:
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.
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.
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.