Showing results for 
Search instead for 
Did you mean: 

Crystal reports- Calculation between two reports

Former Member
0 Kudos

Hi Experts

I have designed a sales and purchase transaction report using crystal reports and i have designed another report for accounting transactions like Excise Duty payable and receivables, Vat payable and receivables, Expenses(like EB, Maintenance) and so on. Finally I added accounting report as sub-report into First Report.

My question is, is it possible to made some calculations between sub-report and main report.

Hope some solutions from you.



Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos


Yes! you can do that by using a sharedvar formula between the two calculations. For example, if you want to calculate VAT in both, then you will be creating a formula

First one will be done in main report

Shared Numbervar x:= {VAT field}

2nd one will be done in sub report

Shared Numbervar x:={VAT field}

The "shared" will be used to calculate.

Additionally you have to link a Main report field with Sub report field. Right click on the Subreport and click on "Change Subreport link", from there you choose the fields which needs to be linked between sub report and main report, in the above case VAT field.

Hope this helps



Former Member
0 Kudos

Hi thanks for your reply

I didn't get u clearly. Links wise ok. but where to give the Shared Numbervar x:= {VAT field}.

My requirement is for e.g i derived a value in report1

Group1-Sum of OINV.DocTotal

similarly in report2 Total expenses

Now I want to calculate

OINV.Doctotal-Total Expenses =Profit

can u show some samples like this.



Former Member
0 Kudos


right upto the linking is good?

Right now you have to create a formula (which you might have already done for "Total expenses", you just need to alternate it slightly.


On 2nd report (subreport) You might have a formula like given below.

Instead of Numbervar CAvg, which is the last shown value in the below formula, you have to make it like Shared Numbervar CAvg.

Numbervar TJs;
Numbervar TotalJobs=0;
Shared Numbervar CAvg;
Shared Numbervar CAvg=0;
TotalJobs := DistinctCount({lab_credits.credit_no},{lab_credits.reason_code});  
CAvg:= TotalJobs /{@WorkingDays};
TJs:=TJs + CAvg;

Do your calculation above.

Now in the main report you will create another formula which will look like below.

Shared Numbervar CAvg;
Numbervar TAvg:=fieldname;
Numbervar TotalBoth:= Shared Numbervar CAvg+ Numbervar TAvg;

You will have a reset formula which will be placed ontop of the report header , group header if you are using grouping like this

Shared Numbervar CAvg:=0;
SHared Numbervar TAvg:=0;

bearing in mind that we do not have to declare CAvg field here as it is being shared.

Hope this helps



Answers (0)