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

dynamic summary 1

Status
Not open for further replies.

gyfu

Programmer
May 28, 2001
77
HK
Guys,
I would like to create a summary on the report footer and based on the details, I want to automatically have the right summary.

This is basically what I have in my details. Not using any grouping.
Code:
Item No. Invoice No. Product Type
1         1234           Type1
2         5466           Type2
3         5456           Type4
So far my summary is something like this and I am using running totals.
Code:
Total count of Type1 1
Total count of Type2 1
Total Count of Type3 0
Total Count of Type4 1
*the total count of type1 are all static text.

1) How can I have it in my summary to suppress Type3 in my summary, since in this particular instance there is no detail on Type3?
2) The other question is that Product Type is pretty much a variable, so how can I have a dynamic summary?


-- gyfu --
Crystal Ver 10
Microsoft SQL
 
By using global variables or buckets - in which you will store the count in the appropriate bucket - and also store the Product Type for that bucket in another variable - that way you can write a formula saying if the bucket is zero - show the next bucket and name.

paulmarr
 
If you only have four "Types" then you can add 4 report footers and add each summary in a separate report footer. Now you can conditionally supress the report footer if the summary is zero.

Kchaudhry
 
paulmarr,
That sounds great but I am having difficulty visualizing how to do it. Could you use my example above and give me some direction please?

thanks.

-- gyfu --
Crystal Ver 10
Microsoft SQL
 
gyfu

Try using 2 formulas like this

Code:
//@Accumulate - Add this to the details ection and suppress)

Shared NumberVar Array ProductType;
Shared NumberVar Array ProductTypeCount;
NumberVar i;

if Not({Product.Product Type ID} in ProductType) Then
(
    Redim Preserve ProductType [Count(ProductType) + 1];
    Redim Preserve ProductTypeCount [Count(ProductTypeCount) + 1];
    ProductType [Count(ProductType)] := {Product.Product Type ID))
Else
i :=1 ;
(
    For i := 1 to Ubound(ProductType)
    Do
        If {Product.Product Type ID} = ProductType[i] Then
            ProductTypeCount[i] := ProductTypeCount[i] + 1
);

0

Code:
//@Display - add this to the report footer section

Shared NumberVar Array ProductType;
Shared NumberVar Array ProductTypeCount;
NumberVar i;

stringVar Display;

For i := 1 to Count(ProductType)
Do
    Display := Display & 'Total count of Type' & cstr(ProductType[i],0,"") & " = " & cstr(ProductTypeCount[i],0,"") & chr(13);

Display

lastly format the Display formula to allow 'Can Grow'

HTH

Gary Parker
MIS Data Analyst
Manchester, England
 
GJParker,
That works like a charm. Thanks a bunch. I knew it could be done in some ways like that but just did not have the programming skill to figure it out. Learn something new today and every day.

-- gyfu --
Crystal Ver 10
Microsoft SQL
 
GJParker,
I have another twist to this report and I hope you can help me with this. Now that everything works fine, I am getting a request where in the summary, instead of displaying "Total count of Type1", I need it to display "Total count of Shoes".

This is where Shoes is the Product Description. In the db table it is something like this.

Code:
Type      Description
1          Shoes
2          Shorts
3          T-Shirts
4          Jackets

I would really appreciate if you could tell me how I can do this with what I already have done. Thanks

-- gyfu --
Crystal Ver 10
Microsoft SQL
 
Hi gyfu

Glad this worked for you.

To record the product description instead of the product code simply change {Product.Product Type ID) to your description field on this line in the accumulate formula

ProductType [Count(ProductType)] := {Product.Product Type ID))

HTH


Gary Parker
MIS Data Analyst
Manchester, England
 
GJParker,
I did tried that before and I got an error saying that a Number is required exactly where you told me to change. I have tried various ways such as trying to change the array to a string, but then I will get error in other places as well.

Please advise. thanks.

-- gyfu --
Crystal Ver 10
Microsoft SQL
 
GJParker,
I got it figured out. Instead I just created another array of string and followed your logic. It works well now. Thank you again.

-- gyfu --
Crystal Ver 10
Microsoft SQL
 
Glad you got it sorted



Gary Parker
MIS Data Analyst
Manchester, England
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top