Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Summay on First Detail Section - Issue Post Reply Post New Topic
Author Message
suresh_haiit
Newbie
Newbie


Joined: 16 Jul 2009
Online Status: Offline
Posts: 4
Quote suresh_haiit Replybullet Topic: Summay on First Detail Section - Issue
     Posted: 28 Jul 2009 at 6:36am
Hi,
I have a report design as follows :
 
G1               (summary Value 1)
    G2           (summary Value 2)
        G3       (summary Value 3)
           D1    100
           D2    200
           D3    250
 
For each G3 (Group Header 3), i need to show only maximum of D3 value. I should hide other details section (D1 & D2). Accordingly I need to sum only those values to G2 and G3.
 
For this solution what I have did is :
1. I have sorted D3 to descending order. and I have created sub-group below to G3, to display only max of D3 value.
 
I want report solution like this :
 
G1               350
    G2           350
        G3       350
           D3    250
        G3       100
          D2     100     
          ...............
.................................................
 
And I have tried by creating running total, we can display value only in the footer. but I want to display the value in  Group header.
 
Could you please help me on this ? I am struck in between.
 
Thanks in advance.
 
Thanks
Suresh
      
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 28 Jul 2009 at 12:15pm
Use the aggregate Max({table.field}) this you can display in the header.  Running Totals is DBlank's specialty...I would use shared variables to keep the totals.
 
I wouldn't bother with displaying details, as it would appear that they are not accessed.
IP IP Logged
suresh_haiit
Newbie
Newbie


Joined: 16 Jul 2009
Online Status: Offline
Posts: 4
Quote suresh_haiit Replybullet Posted: 28 Jul 2009 at 12:31pm
Hi,

Thanks for your input. i am not getting your suggestion. Could you please tell me in a much simpler way ?

I am clear with displaying record by taking max of {table.field}. I wanted to know that how to use shared variables to calculate total in group header ?

As far as i know that we can suppress the detail section with being displayed, do you mean to say that ?

Could you please clear my queries ?

Thanks in advance.

Thanks
Suresh
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 28 Jul 2009 at 1:22pm
yes, not displaying the details is the same as suppressing the details.
 
shared variables are really easy.  just declare them and they are available to you.  typically you need 3 formulas. 1 to reset, 1 to increment and 1 to display.
 
reset...usually in a group header
shared numbervar aVar :=0;
 
display...usually in a group footer
shared numbervar aVar;
 
increment, usually in details
shared numbervar aVar := MAX({table.field},{group});
 
:= is for assignment
= for comparison
 
Hope this helps.
IP IP Logged
suresh_haiit
Newbie
Newbie


Joined: 16 Jul 2009
Online Status: Offline
Posts: 4
Quote suresh_haiit Replybullet Posted: 28 Jul 2009 at 11:56pm

Hi Lockwelle,

Thanks again for your input.
Your solution works fine, to display sum calculate value at Group footer.
But I want to display sum value at group header.
Because I have hierarchy like this, (Users will be drilling down to low lower).
G1               400
    G2           400
        G3       400
           D3    250 (suppressed)
        G3       100
          D2     100 (suppressed) 
        G3       050
          D2     050 (suppressed) 

I need to show the  added sum at header on each group.

Please let me know asap.
 
Thanks
Suresh

 
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 29 Jul 2009 at 6:07am
can't be done....you would need to use a subreport...Crystal can show the max in a header but you need to 'read' the data for the sum that you are after.
 
A subreport would read the data, but it will slow the report down, as you are in effect reading the data once for the inital retrieval, and once (again) for every group...so if you have 50 groups, you will hit the database 51 times.
 
If you can, write a stored proc, and use SQL to get the max, and you can have it add the values together, or have it zero out the max column except for where the values are the max, and then Crystal can add it up just fine in the header.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum