Is there any way of doing this inside the report? I had already seen this tip and tried to use Calc section. I was hoping there was a tip on using it
My report has 2 sections. Section one is the main dataset with a pipeline. Section two is a subreport placed inside the detail band of section one. The data linked and shown correctly. The problem is this percentage of total column. This is the code I am using inside the report:
procedure PrecGrupoOnCalc(var Value: Variant) begin if Report.SecondPass then begin {ShowMessage('Second pass');} if GroupTotal.Value<>0.0 then Value := {100 * JobsCustos['ESTIMADO_TOTAL'] /} GroupTotal.Value else Value := 0.00; end; end;
If I set ppReport to 1 pass then the Percentage column (SubReport) isn´t calculated. (displays 0.0%) If I set ppReport to 2 passes then the Percentage column is accumulated. If I set ppReport to 2 passes and the ChildSection to 2 passes then in preview the pass of the ChildSection is set automatically back to one while the report is generating, and back to two once it´s ended.
The above is fired but returns an unexpected result.
Since you're using a master detail setup then I am assuming that your 'group' lies within the context of a detail subreport. In this case your calculations are limited to within the subreport. You should be able to do group totals then by keeping a total for the subreport and then performing the calculation pretty much as you have below. The subreport must be two pass because on the second pass is when the calculation takes place. Whether the main report is one or two pass doesn't have any effect on this since all your calculation are taking place within the context of each detail subreport.
But this is exactly the problem. I set the TppSubReport to two passes and when previewing the report the object inspector show the passSetting property going to One (generate the report) and back to two (once its done). Why?
Comments
http://www.digital-metaphors.com/tips/PercentageOfGroupTotal.zip
--
Cheers,
Alexander Kramnik
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
Thanks for you assistance.
Is there any way of doing this inside the report?
I had already seen this tip and tried to use Calc section.
I was hoping there was a tip on using it
My report has 2 sections.
Section one is the main dataset with a pipeline.
Section two is a subreport placed inside the detail band of section one.
The data linked and shown correctly.
The problem is this percentage of total column.
This is the code I am using inside the report:
procedure PrecGrupoOnCalc(var Value: Variant)
begin
if Report.SecondPass then begin
{ShowMessage('Second pass');}
if GroupTotal.Value<>0.0 then
Value := {100 * JobsCustos['ESTIMADO_TOTAL'] /} GroupTotal.Value
else
Value := 0.00;
end;
end;
If I set ppReport to 1 pass then the Percentage column (SubReport) isn´t
calculated. (displays 0.0%)
If I set ppReport to 2 passes then the Percentage column is accumulated.
If I set ppReport to 2 passes and the ChildSection to 2 passes then in
preview the pass of the ChildSection is set automatically back to one
while the report is generating, and back to two once it´s ended.
The above is fired but returns an unexpected result.
What am I missing?
Regards,
Clément
'group' lies within the context of a detail subreport. In this case your
calculations are limited to within the subreport. You should be able to do
group totals then by keeping a total for the subreport and then performing
the calculation pretty much as you have below. The subreport must be two
pass because on the second pass is when the calculation takes place. Whether
the main report is one or two pass doesn't have any effect on this since all
your calculation are taking place within the context of each detail
subreport.
--
Cheers,
Alexander Kramnik
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
But this is exactly the problem.
I set the TppSubReport to two passes and when previewing the report the
object inspector show the passSetting property going to One (generate
the report) and back to two (once its done). Why?