cancel
Showing results for 
Search instead for 
Did you mean: 

How to write formula to calculate results based on if statement

Former Member
0 Kudos

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?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Answers (2)

Answers (2)

Former Member
0 Kudos

Thank u, Thank u, Thank u Raghavendr!!!!

Your suggestion worked in the detail section of the report (basically gave me a running total). However, I did have to create another formula (@calculatedtotal) and placed it in the report section so that it picked up my final total. Thank you so very much!!

Former Member
0 Kudos

Hi BJ,

Remove the group field from formula and place it on grand total.

Thanks,

Sastry

Former Member
0 Kudos

Do you mean:

If {@IsComp} = "Yes" then Sum ({checkbook.ASSIGNMENT_LABORHRS})

else if Sum ({checkbook.ASSIGNMENT_LABORHRS})<Sum ({@LaborTotal})

then Sum ({checkbook.ASSIGNMENT_LABORHRS})

my report total is now 0. I think it's looking at the last record only.