Same Totals??
PixelPointer
Vaughan, Ontario
<span style='color:blue'>With my current assignment at work, I am certainly running up a few forum posts. I apologise for posting so much, I usually spend about an hour or so trying to find the solution myself, and then I post here. So, here we go again...</span>
I am attempting to sum up Totals for the entire report, and totals for a grouping, and use each in the same row, for different calculations. Basically, I am finding the percentage usage on a whole, and the percentage usage by a summary group. Here is the code that I am using:
The issue that I am running into, is that both totals are showing up the same. Where I want the <span style='color:purple'><extRCRevenues></span> variable to hold the sums for each summary group, and the <span style='color:purple'><extSGRevenues></span> to hold the summary for the entire report.
As always, any assistance is GREATLY appreciated.
I am attempting to sum up Totals for the entire report, and totals for a grouping, and use each in the same row, for different calculations. Basically, I am finding the percentage usage on a whole, and the percentage usage by a summary group. Here is the code that I am using:
procedure ReportSummary1OnBeforePrint(Sender: TfrxComponent);
begin
   if not Engine.FinalPass then
   begin
       //Sum the prices and profit dollars for the entire report                                                             Â
       Set(<extSGRevenues>, Sum(<Price>, MasterData1,1));
       Set(<extSGProfitDollars>, Sum(<ProfitDollars>, MasterData1,1));
   end;
end;
procedure gfSummaryGroupOnBeforePrint(Sender: TfrxComponent);
begin
   if not Engine.FinalPass then
   begin
       //Sum the prices and profit dollars only for summary group                                                             Â
       Set(<extRCRevenues>, Sum(<Price>, MasterData1));
       Set(<extRCProfitDollars>, Sum(<ProfitDollars>, MasterData1));
   end;
end;
The issue that I am running into, is that both totals are showing up the same. Where I want the <span style='color:purple'><extRCRevenues></span> variable to hold the sums for each summary group, and the <span style='color:purple'><extSGRevenues></span> to hold the summary for the entire report.
As always, any assistance is GREATLY appreciated.
Comments
This is a portion of my code, if anyone has the time to look @ it.
I have about 10 reports to write, that are similar to this one, but this one has taken me over a week!!! So, if anyone has a solution, I will certainly give it a try, and will be very appreciative.
Thank you.
Actually, it don't use Script, but a memo expression.
Have you tried it?
Btw: FastReport is an excelent Report tool if you never try to use its Script!
You are probably setting values in the wrong place or event.
Frustration usually comes from hacking code from demos and trying to adapt without understanding why and where it was written.
Been there done that.
variables declared at the top of the code page are global to the report
can be used in any object event and displayed in a memo by enclosing in [ ]
you can initialize them in the empty begin end block at the bottom of the code page no need to add a procedure to initialize them, this is the first piece of code to run. one must pay attention to where they may be reinitialized
they can be retreived/modified with out using the get set methods, which are used with categorized variables in the variable list.
the best bet is to design layout first then write the code to suit
a lot of things can be accomplished just using expressions and functions in the memos themselves, also setting the displayformat prop of the memo and using an intermediate var for display purposes can save writing a lot of code converting to formated strings and changing text of memos.
one caveat when using grouping it will not perform correctly with unidirectional datasets like DBX.
(1) being able to do calculations based on summed columns from various levels of grouping
(2) an automated export to csv
Once I conqueur those two issues, I am off to the races. :-) I will continue to plug away, and hopefully I will get these variable settings working.
when you preview the report you should be able to export to the format of your choice.
read the usermanual chapter on working with aggregates around pg 61 IIRC
BTW what version of fr and delphi are being used?
For Delphi, it is V5, for FR it is 3.20.
I have read the aggregates functions in the manual, and I am pretty sure that I have a good idea of how they work, however, I still can't get this thing to work. At first, the task seemed pretty simple, add up 3 columns, take the sum at the bottom, and divide each value in the list by the sum to get the percentage of total for each value. I was able to get one column to work, but thats it so far.
As for exporting, I can export manually from the reports, but I am tring to put together a script that will allow the customer to use our scheduler to schedule the reports, and have them exported automatically. :-(
Since my last bad attitude post, I have built quite a number of simple reports in Fast Reports, and I was able to build them quite quickly. Its just these last two issues that have created a dent in my desk the size of my forehead.
i.e.
Sales | % of Sales
$12 | 0.150
$10 | 0.125
$34 | 0.425
$24 | 0.300
$80 | 1.000
ill post a modified version of 45.frf from the main frdemo for you
the subject will be modified frf for pixelpointer.