cancel
Showing results for 
Search instead for 
Did you mean: 

WhilePrintingRecords summary forumula problem

Former Member
0 Kudos

Hello

I have used the WhilePrintingRecords function (full formula below) on a number of reports in order to create a sum of a field which appears in the group footer. In order for the field to work properly it needs to be included at the group level and report footer level. It is working correctly on a number of reports but on one report the 'total' value in the report footer is 1 higher than the incremental count on the last group footer. In my investigations I removed the field from the group footer and the value on the field in the report footer is '1' (it should be '0'). If I do this on one of the reports that works, the value in the report footer is '0' which is correct.

Would anyone be able to provide assistance or shed light on what may be happening to produce this erroneous value?

Many thanks in advance

WhilePrintingRecords;

NumberVar Report_Summary_Field:=Report_Summary_Field  + {@formula field};

Accepted Solutions (1)

Accepted Solutions (1)

abhilash_kumar
Active Contributor
0 Kudos

Hi Matthew,

The value on the Report Footer cannot be '1' unless there is another formula that initiates the variable to '1' in some other formula.

Could you also paste the code for @formula field?

-Abhilash

Former Member
0 Kudos

Hi Abhilash

The forumula there is:

if isnull (Sum ({@forumula_1},{table_1.field_1}))then 0 else

if Sum ({@formula_1},{table_1.field_1})>= 1 then 1 else 0

Basically for each group if the condition in @formula_1 is met I want a '1' returned in order to use in the incremental count. I used this formula as the condition may be met several times in a group but I only want to count it once for each group.

Your remark to initiating the variable to '1' seems to hold weight but please bear in mind that this same configuration seems to be working on other reports.

Many thanks!

Matthew

abhilash_kumar
Active Contributor
0 Kudos

A formula can never return a Null, so the first line of the code can be removed. Try this:

whileprintingrecords;

numbervar grand_total;

if Sum ({@formula_1},{table_1.field_1}) >= 1 then

     grand_total := grand_total + 1;

Place this formula on the Group Footer.

Create another formula to display the Grand Total on the Report Footer as:

whileprintingrecords;

numbervar grand_total;

-Abhilash

Former Member
0 Kudos

Hi Abhilash

You've done it! You are wonderful, thank you!

Just out of interest, if I removed the if isnull line from my formula the old grand total field returned incorrect values (even in the reports I thought worked) because the details section sometimes has no lines for some groups. It seemed to work better when I enforced the '0' value in this eventuality, but it's academical anyway as I will be using your formulas above.

Thanks again!

Matthew


Answers (0)