Adding Sub reports ,Find Sub Total and Grand Total(To main Report)

Crystal Reports is a business intelligence application used to design and generate reports from a wide range of data sources. Sub Reports are child reports of the main report which can be embedded in main report. Sub reports are very much useful in building reports.

Adding Sub reports find the sub total and grand total of each sub report in the main report

Main report

Sub Report 1

Sub Total: sum (LabTotal )

Sub Report 2

Sub Total: sum (ItemTotal)

Grand Total

Sub reports are very useful option in crystal report. Suppose we want to find

Adding Crystal report

1. Add New Item->Crystal Report
2. If we want to create Crystal Report our own format select “As a Blank Report” from crystal report gallery
3. Right Click on the “Database fields” in the Database fields and select tables from the database then make Links (if necessary)
4. Right Click from “Details Section” and Add sub report.
5. Repeat the same things that we have done in the main report and drag needed fields to details section sub report

For Eg: We are creating labour report the total labour rate can be calculated as

In Formula field –name LabTotal

Shared NumberVar LabTotal := Sum ({PC_LABOUR_DETAILS.Total})

Total ---field

and add sum of LabTotal in to the sub total field

If we have another sub report to add ion the main page ,again right click on the “Details Section” and add new section ->Details(b)
And repeat step 4 and 5
Here we are adding second sub report for material and subtotal of materials can be caculated as

In Formula field –name ItemTotal

Shared NumberVar ItemTotal := Sum {PC_MATERIAL_DETAILS.Total})

Total -- field

and add sum of ItemTotal in to the sub total field

Main report

To find the grand total of both sub reports

In Formula field name-GrandTotal

Shared NumberVar ItemTotal;
Shared NumberVar LabTotal;
NumberVar TotalAmount;
TotalAmount := ItemTotal+LabTotal;


  • Screen Shots (26316-2363-crystalreport.doc)
  • Comments

    Author: Shailesh Patil08 Sep 2010 Member Level: Bronze   Points : 1


    I have followed the instructions and placed the formula in subreport and main report.
    For testing purpose i printed the subreport formula and it worked.
    But in main report it still shows as zero.
    Would you please help me in this.

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: