Sum Amount of Previous Page and Current Page

You can use the Totals Collection property of the DataBand element to calculate sum of current and previous report pages.

For example, there is a need to create a report, including any data column, where you see the total sum of values from previous pages in the top and the total amount of current and previous pages in the bottom:

 1-2 Pages   2-3 Pages  

  

  

Add a new item to the Totals Collection property of the DataBand element, set the Name (for example, "Sum"), set the AggregateFunction to Sum, use the LineNumber method to specify the expression (to provide a summation of values from each row):

Then set the following expressions in the Generate Script property of the textboxes where the sum is calculated:

 Designer   Script Editor  

  

if (Engine.IsDoublePass)
{ 
textBox1.Text = kkk1.ToString();
}
 Designer   Script Editor  

  

if (Engine.IsDoublePass)
{  
kkk1 = kkk;
kkk += 
dataBand1.GetPageTotal
("Sum",PageNumber);
textBox3.Text = 
kkk.ToString(); 
}

This sample is available for downloading at the next link: SumAmountUsingTotals.zip

Add Feedback