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) )
Hi, very interesting on how you did that. Can you let me know how you added in the groupbyrow the summary columns please?
Thanks a lot.
Alex
Hello Alex,
You can OR together the various options for SummaryDisplayArea to get the behavior you want. I used the following combination:
BottomFixed: Show totals at the bottom and always visible (no scrolling)
InGroupByRows: show group summaries in group by rows
GroupByRowsFooter: shows grand summaries
Me.UltraGrid1.DisplayLayout.Override.SummaryDisplayArea = Infragistics.Win.UltraWinGrid.SummaryDisplayAreas.BottomFixed _
Or Infragistics.Win.UltraWinGrid.SummaryDisplayAreas.GroupByRowsFooter _
Or Infragistics.Win.UltraWinGrid.SummaryDisplayAreas.InGroupByRows
Hope this helps,
Ben
Thanks a lot, i will try it