So my problem is I have created a report which is grouped by Dealer number. Within this group I have created running totals to summarize the volume of each dealer, then just display their total volume. I reset all my variables to 0 in the group header. When I look at the report in CR it looks fine. But through the viewer or exported to excel -data only it just displays an ongoing running total. Seems like its not reseting to 0 in the group header. Any thoughts would be appreciated. Could problem just be with viewer if its displaying properly in CR?
In Report Header:
whileprintingrecords;
global numb开发者_运维问答ervar volume := 0;
In Detail Section of Group: Formula Field
if Month({appl_trans.trans-dt}) = 1
and Year({appl_trans.trans-dt}) = Year(CurrentDate) then (
if previousisnull({contract1.contract-no}) then
global numbervar volume := {contract1.cost-base};
if {contract1.contract-no} <> previous({contract1.contract-no}) then
global numbervar volume := volume + {contract1.cost-base}
else
global numbervar volume := volume
);
In Group Header :
whileprintingrecords;
global numbervar volume := 0;
In Group Footer : Formula Field
whileprintingrecords;
global numbervar volume := volume;
Your variable usage is overly complicated and CR might be doing odd things because of it. Get rid of the formula in the report header completely - you're already reinitializing the variable in the group header. Next, change the formula in the details section to something like this:
whileprintingrecords;
global numbervar volume;
if (Month({appl_trans.trans-dt}) = 1
and Year({appl_trans.trans-dt}) = Year(CurrentDate)
and {contract1.contract-no} <> previous({contract1.contract-no}) then
volume := volume + {contract1.cost-base};
Keep the formula in the group header as it is. Then use this formula to display the volume in the footer:
whileprintingrecords;
global numbervar volume;
volume
You generally only want to declare a variable once per formula, meaning only one "global numbervar x" and do it for every formula where that variable is used. You also will never need to set a variable to itself, as it won't actually do anything.
Another way to accomplish this that might be simpler than using formulas is that you could just add a Running Total field to sum {contract1.cost-base}, evaluate on change of {contract1.contract-no} and reset after each group. Or yet another way is to add another inner grouping on {contract1.contract-no} and insert a Summary field in the group footer. Either way will get the job done.
精彩评论