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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Groups with null data. 1

Status
Not open for further replies.
May 5, 2004
29
GB
Hello all. Have put together a report where it's broken down by group. there are 4 groups A, B, C and D How do I print the zero stats for say group C even if there were no records coming through for that group? I know there's a suppress section if null but that's not helping.

Much thanks.
 
The short answer is that crystal wil only create group for data that exists in your records retrived from teh db.

If your group field exists in a table that can be outer joined to the other table(s) used in your report then you can do this to always retreive group fields.

It is difficult to supply a solution as you haven't provide enough data about your data structure, input or output.

HTH

Gary Parker
MIS Data Analyst
Manchester, England
 
Code = A

2343
33
97
9

Code = B

122
20

Code = D

9
43
12
903

This is the structure I have and is grouped by code
I break it down by code and print the variables beneath the
code (group) headings.
How do I print the heading and the zero that would account for
code C if no records/figures were selected for it?

Thanks
 
As GJ pointed out, crystal works with what you supply, it doesn't fabricate data.

So cheat this using something like:

Right click the group header field and select insert section below.

In the new section place a formula of:

whileprintingrecords;
Stringvar Output:="";
numbervar counter;
if onfirstrecord
and
{table.groupfield} <> "A" then
for counter := asc("A") to asc({table.field})-1 do(
Output:=Output+chr(counter)+chr(13)+"0"+chr(13)
);
else
if asc({table.groupfield}) <>
asc(previous({table.groupfield})) + 1 then
for counter := asc(previous({table.groupfield}))+1 to
asc({table.groupfield})-1 do(
Output:=Output+chr(counter)+chr(13)+"0"+chr(13)
);
left(Output,len(Output)-1)

Make sure that you right click the formula and select format field Can Grow.

Then right click the new section and select format section X2 next to the suppress and place:

{table.groupfield} = "A"
or
asc({table.groupfield}) =
asc(previous({table.groupfield})) + 1

This all assumes that your fields are truly called A,B,C,D...etc...

-k
 
Again difficult without a complete description of the problem but if you have the option on the data side you can create a table with the group names (A,B,C,D ...) and then do an outer join with your data table to return all your headings even if there is no matching data in the main table.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top