0

# How to calculate the sum of Formula Fields

May 01 at 11:19 AM

26

Former Member

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

report.png (43.2 kB)

Ian Waterman May 01 at 02:13 PM
0

As you are using Variables you need to use another one

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

Show 2 Share
Former Member

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

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

Ian

Former Member May 01 at 11:29 AM
0

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

Share