Print Page | Close Window

customize group at crystal report

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=14948
Printed Date: 20 Apr 2025 at 6:50am


Topic: customize group at crystal report
Posted By: melvintcs
Subject: customize group at crystal report
Date Posted: 15 Nov 2011 at 5:37pm
Database:

Category        total

     A                 100

     A                  80

    B                   50

    C                   90



Crystal Report:

    C                 90

    A               180   Total 1: 270     



    B                 50    Total 2: 50

--------------------------------------------

                               Total 3: 220 (Total 1 - Total 2)

---------------------------------------------

I able to group the category, but it group/give me the total of 'A', 'B', 'C' accordingly. how i can get the value, something like set it to variable and use it later?

There are few condition i want to make

1) I able to rearrange the category. (which come first)

2) able to use 'total 1', 'total 2' anyhow i wanted it to be.

below is the sample picture i used for the report, please advice... =)




Replies:
Posted By: melvintcs
Date Posted: 16 Nov 2011 at 9:02pm
no one can help me? or i make the question easier:

How i can get the value of "Total 1 - Total 2"?


Posted By: lockwelle
Date Posted: 17 Nov 2011 at 4:27am
I don't have time to check in on all the forums, as someone else mentioned, we are volunteers, well enough of that line...
 
you can create a shared variable (or global, your choice) to save a value and use it later, like:
shared numbervar lastTotal;
local numbervar thisTotal := sum({table.field}, {group});
local numbervar dispTotal := lastTotal - thisTotal;
 
lastTotal := lastTotal - thisTotal;
dispTotal;
 
or something like that if you wanted.
 
rearranging the groups is another issue, and it depends on what you want to rearrange on.  You might be able to reorder them based on an Aggregate function, like SUM, but I haven't tried it myself.
 
Usually, my rule of thumb is you can change the grouping dynamically by using values that is in your 'raw' data, whatever is in your tables or is the output of a stored proc or view, and while an Aggregate is kinda in the 'raw' data, I am not sure that CR will do it.
 
If you wanted to rearrange them based on a shared variable, it won't work, as the value is not known until after group is done being printed, at which point it is too late rearrange the data.
 
HTH



Print Page | Close Window