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

Don't sum the column's value which are supressed. How? 1

Status
Not open for further replies.

CrystalReports9

Programmer
Jan 10, 2003
124
US
Could someone please tell me how I can sum the distinct repeating value of the records that are displayed on the report at the same time not suming values that are supressed.

GH1 <detail>
-----------
Value
100

GH2 <detail>
------------
Value
100
100
200

GH3 <detail>
------------
Value
100
100

After suppressing the repeating values (without condition)

GH1 <detail>
-----------
Value
100

GH2 <detail>
------------
Value
100
<<-- Value 100 is suppress
200

GH3 <detail>
------------
Value
100
<<-- Value 100 is suppress
---------
Total 400 <<---- How to get this total ????
----------

How to get the Total 'value' 400 (GH1 value + GH2 Value + GH3 Value) ???
 
Why would you get $400, the distinct sum should be $500, shouldn't it?

GH1 <detail>
100
GH2 <detail>
100
200
GH3 <detail>
100
total:= 500

Also, are these 3 different headers, or 3 iterations of the same one? There isn't a GH1, GH2, GH3 Detail in Crystal, so your example is confusing.

GH2 is how Crystal designates a separate header, not the second instance of a Group.

Also keep in mind that repeating values may be because there are 2 of the same values which should be distinct, assuming duplication may bite you later.

Anyway, to sum distinct totals in a single Group, you can use a formula in the group header such as:

whileprintingrecords;
numbervar Total;
if {table.field}<>previous({table.field}) then
Total:=Total+{table.field}

Then at the report footer use:
whileprintingrecords;
numbervar Total:=Total+{table.field};

I would suggest posting technical information about your environment and requesting assistance with design and theory in lieu of specifics:

Crystal Reports version
Database/connectivity used
Example data
Expected output

-k
 
If SV is right and the total is 500, then you could also use the running total expert and select {table.amt}, sum, evaluate on change of field, reset never. For the evaluation section, you should use whatever field tells you that a value is unique versus a duplicate. For example, you might have an ID field that is unique to a record:

table.id value
101 100
102 100
103 200

In this case, you would want to sum both "100's". You would add {table.id} in the on change of field section, or better yet, group on it and choose evaluate on change of group (ID). Then place the running total in the report footer.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top