Add a blank section, and the totals change?

Friday 20 June 2014 @ 10:13 pm

A customer sent me a report today with an unusual behavior. There was a total on the report and the problem was that the total would change when she unsuppressed a details section and change back when she re-suppressed the details. Even adding a blank details section made the total change.

At first I figured she had to be mistaken. I could think of no way that suppressing a section or splitting a section could have an effect on totals. But as I thought about it I realized there was one one obscure way. Both of the changes she mentioned could change the number of pages. And there is one way that adding pages can affect totals.

There is a property in the group expert that allows you to repeat a group header on each page. This allows you to repeat the label of a group when that group spills over to a second or third page. So say you are creating running totals using variables. And also say that there is a formula that increments or resets the variable in the group header. By adding more pages to the report you would be adding repeated group headers, and this would repeat the variable assignment more often than intended.

So I opened the report and located the total that was changing. As I suspected, it was based on a variable. Then I checked the Group Expert and found that Group 1 had the option set to repeat the headers on each group. Last, I looked at that group header and found the reset formula for the variable. When I changed the group property to NOT repeat the header, the total no longer changed when I suppressed or unsuppressed the section. So that was one solution.

An even better solution, especially if you really need to repeat the Group Header, is to alter the formula so that it doesn’t make a variable assignment in repeated sections, but only in the original. There is a function specifically for this that you use as follows:

NumberVar XYZ;
If not InRepeatedGroupHeader then XYZ := 0;

This would reset the variable at the beginning of each group, but not when the Group Header repeats.


(For examples of my most popular formulas, please visit the FORMULAS page on my website.)

Leave a Reply

Recrystallize Pro

Crystal Reports Server