# How to write formula to calculate results based on if statement

Hello everyone! I'm new to this forum stuff so please be patient!!

I have this formula field:

If {@IsComp} = "Yes" then Sum ({tablename.ASSIGNMENT_LABORHRS}, {tablename.WONUM})

else if Sum ({tablename.ASSIGNMENT_LABORHRS}, {tablename.WONUM})<Sum ({@LaborTotal}, {tablename.WONUM}) then Sum ({tablename.ASSIGNMENT_LABORHRS}, {tablename.WONUM})

else if Sum ({@LaborTotal}, {tablename.WONUM})<Sum ({tablename.ASSIGNMENT_LABORHRS}, {tablename.WONUM}) then Sum ({@LaborTotal}, {tablename.WONUM})

As you can see this field is totaled for group WONUM. I want to calculate a grand total for the report. I cannot use a Running Total and cannot determine a formula that should be used. Can anyone help?

##### Guest replied

Try to use mannual running totals.

Create a formula as you mentioned before like

@Total: If {@IsComp} = "Yes" then Sum ({tablename.ASSIGNMENT_LABORHRS}, {tablename.WONUM}) else if Sum ({tablename.ASSIGNMENT_LABORHRS}, {tablename.WONUM})<Sum ({@LaborTotal}, {tablename.WONUM}) then Sum ({tablename.ASSIGNMENT_LABORHRS}, {tablename.WONUM}) else if Sum ({@LaborTotal}, {tablename.WONUM})<Sum ({tablename.ASSIGNMENT_LABORHRS}, {tablename.WONUM}) then Sum ({@LaborTotal}, {tablename.WONUM})

and now create another formula like

@CalculateTotal: whileprintingrecords; numbervar i; i:=i+@Total;

place this formula in detail section and see the out put.

If it doesn't work try to place this in group footer or header and sse the output.

Regards,

Raghavendra