My objective is to perform this calculation: Field2/Field1 = Field3.
this.ugSalesStats.DisplayLayout.Bands[0].Summaries.Add("Field1", SummaryType.Sum, this.ugSalesStats.DisplayLayout.Bands[0].Columns["Field1"]); this.ugSalesStats.DisplayLayout.Bands[0].Summaries.Add("Field2", SummaryType.Sum, this.ugSalesStats.DisplayLayout.Bands[0].Columns["Field2"]); this.ugSalesStats.DisplayLayout.Bands[0].Summaries.Add("Field3", SummaryType.Sum, this.ugSalesStats.DisplayLayout.Bands[0].Columns["Field3"]);
I'm aware the above syntax won't get it done. My intent above is to illustrate what I'm trying to accomplish.
I've read several KB articles related to my objective but I can't quite figure out the appropriate syntax.
To sum it up, I want to divide two summery row fields and place the result in a third summay row field.
Field1 Field2 Field3
1234 711 57
Thanks for taking a look.
You're right. The second row cell was appended to the first row cell. As you suggested , I removed the first row reference to that specific cell and it worked our perfectly.
Thanks Michael.
It looks like you are adding two summaries to the Field3 column and I think you only want one.
Mike & Mike:
Thank you for your responses. I used a snippet of your code to get the above results.
I'm on the right track but I'm missing or not understanding something.
This is the calculation I’m performing:
SUM([Field1]) / SUM([Field2]) = Field3
Field1 = 1422, Field2 = 2538, Field3 = 0.56028.....
The number 0.56028..... should replace 53.6 on the first summary row and should equal 5.60.
No second summary row should appear.
Below is the code I used to get the above results.
The last line of code seems to add the second summary row and is probably the row that needs replacing or modifying..
I've tried several combinations of syntax and when I think I got right it doesn't happen.
Again, thanks.
this.ugProStatPassingSeason.DisplayLayout.Bands[0].Summaries.Add("Field1", SummaryType.Sum, this.ugProStatPassingSeason.DisplayLayout.Bands[0].Columns["Field1"]);
ugProStatPassingSeason.DisplayLayout.Bands[0].Summaries["Field 1"].DisplayFormat = "{0}";
this.ugProStatPassingSeason.DisplayLayout.Bands[0].Summaries.Add("Field2", SummaryType.Sum, this.ugProStatPassingSeason.DisplayLayout.Bands[0].Columns["Field2"]);
ugProStatPassingSeason.DisplayLayout.Bands[0].Summaries["Field2"].DisplayFormat = "{0}";
this.ugProStatPassingSeason.DisplayLayout.Bands[0].Summaries.Add("Field3", SummaryType.Average, this.ugProStatPassingSeason.DisplayLayout.Bands[0].Columns["Field3"]);
ugProStatPassingSeason.DisplayLayout.Bands[0].Summaries["Field3"].DisplayFormat = "{0:###.#}";
UltraGridLayout layout = e.Layout;
ultraGridBand band = layout.Bands[0];
band.Summaries.Add("SUM([Field1]) / SUM([Field2])", SummaryPosition.UseSummaryPositionColumn, band.Columns["Field3"]);
I have attached a sample application which illustrates what Mike described. Let me know if I left anything out.
Hi,
There's no way to do this using the built-in summary types like SummaryType.Sum. But you could do it using Formula summaries.
First, make sure you have an UltraCalcManager component on the form with the grid. You need it in order to use formulas.
When you add your summaries, you need to specify a Key and a formula for each one.
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { UltraGridLayout layout = e.Layout; UltraGridBand band = layout.Bands[0]; band.Summaries.Add("Field1Sum", "Sum([Field 1])", SummaryPosition.UseSummaryPositionColumn, band.Columns["Field 1"]); band.Summaries.Add("Field2Sum", "Sum([Field 2])", SummaryPosition.UseSummaryPositionColumn, band.Columns["Field 2"]); // When referencing a summary in a formula, you have to use parens at the end of // the summary key. This is so the grid can distinguish a summary key from a // column key. band.Summaries.Add("Field3Sum", "[Field1Sum()] / [Field2Sum()]", SummaryPosition.UseSummaryPositionColumn, band.Columns["Field 3"]); }