Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grouping of totals based on a field

Status
Not open for further replies.

longfellow

IS-IT--Management
Mar 28, 2002
75
IN
I have got the following columns in my report
Callid, QNAME, Calls, Abandoned Calls. Now i have a page total as well as grand total at the end of the report. I want totals grouped by QNAME without disturbing the page total or the grand total.what should i do in Crystal Report to get this ?

Vers CR 9, VB 6, SQL Server 2000

Thanks
Longfellow
 
The standard answer for this is to sum the values in variables for each page. E.g.

Place this in the Page Header section and suppress it
//@Reset
WhilePrintingRecords;
Shared NumberVar RTotal :=0;

Place this in the whichever section contains the field you want to total
//@RunningTotal
WhilePrintingRecords;
Shared NumberVar RTotal := RTotal + {Field to total};
RTotal

Place this in the page footer section
//@Display
WhilePrintingRecords;
Shared NumberVar RTotal;
RTotal

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Madawcs solution will give you the page totals, but to show group totals at the end of the report, you would either use variable arrays to calculate and hold the totals. Or a simpler approach woudb e to create a subreport to group the data as required and place this in the required section.

HTH

Gary Parker
MIS Data Analyst
Manchester, England
 
I did'nt understand what you mean by Grouping data in subreport and placing it in required section

Can you explain

Thanks

Longfellow
 
create a subreport that groups the data, and place this subreport in the required section i.e. Report footer

HTH

Gary Parker
MIS Data Analyst
Manchester, England
 
If you want totals grouped by a name, then insert group and get group summary totals.

There are several ways: running totals, summary totals, grand totals and variables. Right-click on a field and choose Insert to get a choice of Running Total, Summary and Grand Total.. Or else use the Field Explorer, the icon that is a grid-like box.
Running totals allow you to do clever things with grouping and formulas. The disadvantage is that they are working out at the same time as the Crystal report formats the line. You cannot test for their values until after the details have been printed. You can show them in the group footer but not the group header, where they will be zero if you are resetting them for each group.
Summary totals are cruder, but are based directly on the data. This means that they can be shown in the header. They can also be used to sort groups, or to suppress them. Suppress a group if it has less than three members, say.
Grand totals are much like summary totals, but for the whole report rather than groups. Note that summary totals include an option to have a grand total calculated on the same basis.
Variables are user-defined fields. I don't use them, except for shared variables to pass data from a subreport back to the main report. You can also use variables to show page totals. For normal counting I find running totals or summary totals much easier.
To get yourself familiar with the idea, try doing a test report with a summary total and a running total for the same field, placed on the detail line. You'll find that the running total increases as each line is printed, whereas the summary total has the final value all along.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Thanks Madawc for those suggestions. I have been working with summary and running totals on test report. I still have a problem of figuring out how to get the exact output.
Eg

I have 3 fields CPNo, Qname and Calls. In my main report i would like to display Each Qname , the various CPNo's for that qname and total calls for each CPN. Upto this part its fine.
eg CPN QNAME CALLS
2364251234 VARTEC_DNS 60
2364251233 VARTEC_DNS 55
2364251232 VARTEC_DNS 55
2364251231 VARTEC_DNS 45
4562351245 Reject 30
4562351245 Reject 10
etc

In my subreport i just want the following to happen . I want to group by Qnames and just want the total number of calls displayed at the end of each QNAME.
from the above example

VARTEC_DNS 215
Reject 40

and on the last page the total . How do i get this? I want the totals for each QNAME to appear in the subreport. Not for each CPNo. How do i do this?




 
Try a 'distinct count' for QNAME.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top