paginationsumcrystal-reportssubtotal

Get sum of a field per page in crystal report


I Have a Crystal Report and get the sum of a field like this:

Sum({TheField})

and I put it in PageFooter section to have it in all pages but if the report has multiple pages it shows the sum of all fields and I need to get the sum per page.

Any ideas how to do that?


Solution

  • You can get page level totals as follows. Create three formula fields in report design, namely ff_Reset_Total, ff_Current_Total, ff_Add_Record and set their values in formula editor as under:

    1. ff_Reset_Total

      whileprintingrecords;
      numbervar PageTotl;
      PageTotl:=0;
      
    2. ff_Current_Total

      whileprintingrecords;
      numbervar PageTotl;
      PageTotl;
      
    3. ff_Add_Record

      whileprintingrecords;
      numbervar PageTotl;
      PageTotl:=PageTotl + {TheField};
      

    Now place these formula fields in your report as under:

    1. ff_Reset_Total in Page Header Section
    2. ff_Current_Total in Page Footer Section
    3. ff_Add_Record in your Details Section

    Now hide ff_Reset_Total and ff_Add_Record by Right Click on each of them in Page Header and Details Sections, point to Format Field and then in the Common tab select Suppress