cancel
Showing results for 
Search instead for 
Did you mean: 

How to calculate the sum of Formula Fields

Former Member
0 Kudos

I m using crystal reports and i have varchar(500) columns which saves date and time for employees like checking in and checking out time , so i want the difference of checkout-checkin so i wrote that below formule

"NumberVar TotalSec := Time({zz_tbl_Report_New_Format.MondayOut}) - Time({zz_tbl_Report_New_Format.MondayIn}); NumberVar Hours := Truncate ( TotalSec / 3600); NumberVar Minutes := Truncate (Remainder ( TotalSec,3600) / 60); Totext ( Hours, '####') + ':'+ Totext ( Minutes,'00');"

it finds the difference correctly now at the end i want to add up all these rows and show the sum how can i achive that .check the attachement for more clarification

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

As you are using Variables you need to use another one

Using your existing formula,

Whileprintingrecords;

Global numbervar GrandTotalSec;

NumberVar TotalSec := Time({zz_tbl_Report_New_Format.MondayOut}) - Time({zz_tbl_Report_New_Format.MondayIn});

NumberVar Hours := Truncate ( TotalSec / 3600); NumberVar Minutes := Truncate (Remainder ( TotalSec,3600) / 60); Totext ( Hours, '####') + ':'+ Totext ( Minutes,'00');"

GrandTotalSec:= GrandTotalSec + TotalSec

Assuming this is a Report Total you will not need to reset GrandTotalSec

Create another Var

@DisplayGT

Whileprintingrecords;

Global numbervar GrandTotalSec;

You can then perform same Truncate and remainder on this to split into Hours and mins, then use Totext() to concatenate numbers together to display as HH:MM:SS

Ian

Former Member
0 Kudos

Ian Waterman i am not getting exactly how to achive the sum of formula field.

Former Member
0 Kudos

Please show full content of your time difference formulae.

Where is formula located and how is report grouped, where do you want total to appear.

Ian

Former Member
0 Kudos

I found the solution

Go to Running total Fields in Field Explorer and right click on it and make your Field For total

and if you have already made your formula then select it and [>] click it to put your formula to Field to Summarize then from Type of Summary Drop Down select Sum and click ok. Now you can see your

New formula at Below List in Running total Fields You can put it where you want to see total.

Regards,

Abhi Patel



BUT IT WONT WORK FOR ME AS I HAVE STRING TYPE SO MY SUMMARY DROPDOWN DOES NOT SHOW SUM it SHOWS COUNT AND OTHER ITEMS LIKE MAXIMUM ,MINIMUM ETC