Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
130
Formula Summary within a Formula Summary in a Group By
posted

Using a Formula Editor at Runtime, I defined a Summary Formula on a Margin column called “Margin:Total Margin” with the value of:

 SUM([Margin]) 

I then used this Formula in another Summary Formula on the Margin Percent column called “Margin Percent:Average” with the value of:

 if( SUM([TotalPrice]) = 0 , 0 , ROUND(  [Margin:Total Margin()]   / SUM( [TotalPrice]) * 100, 2) )

The “Margin Percent:Average” formula works correctly in Group By Summaries and Grand Summaries right after exiting the Formula Editor and creating/updating the SummarySettings entry in the Band.  However, “Margin Percent:Average” evaluates to 0 in all Group By Summaries after refreshing the data.  It still evaluates correctly in the Grand Summaries section after the refresh.

I know this could be resolved by not using a formula within a formula, but I’m using this as a test case for what users might do at runtime.  Does anyone have any suggestions on how to get around this issue in the Group By summaries?

I don’t know if this makes a difference or not, but both the Margin column and Margin Percent column are based on formulas.  Margin is:

[TotalPrice] - [TotalCost]

Margin Percent is:

if( [TotalPrice] = 0 , 0 ,    ROUND([Margin] / [TotalPrice] * 100, 2) )