franz312
franz312

Reputation: 13

Crystal Report: How do you add distinct values?

For example I have:

Supplier GroupName

ID name value

01 chair 5,000

02 table 3,000

03 mantle 4,000

01 cabinet 5,000

02 closet 3,000

The total result should be 12,000 since the ID was repeated.

another example is this: https://i.sstatic.net/Yp2Qr.jpg

the total for cash should be 75,000 based on the SOS#

Upvotes: 0

Views: 10978

Answers (3)

Pratik Kaje
Pratik Kaje

Reputation: 715

try this.

1] Order your result set on ID column. This will bring all your repeating ID's together.

2] Add one formula in the details section. In that formula write

if previous({Command.ID}) <> {Command.ID} then 1
else 0

This formula will show 1 and 0's in the details section. Lets name that formula as @test (You can suppress it)

3] Now add one more formula in detail, say @test1. In that formula write

Shared numbervar num;
if {@test} = 1 then 
num:=num + {Command.Value};
num;

(Suppress this formula too)

4] Group header add one formula say @test2. In that formula write

Shared numbervar num;
num:=0;

5] In group footer add one formula say @test3. (This formula will be your Sum of the totals in details.i.e. your expected sum) Write below code in this formula

Shared numbervar num;
num;

This will help! Thanks!

Upvotes: 0

DevelopmentIsMyPassion
DevelopmentIsMyPassion

Reputation: 3591

1 In the Field Explorer >> Right Click 'Running Total Fields' >> New

2 In the Create Running Total window select the choices as following:

Field to summarize: YourColumnName Typeof summary: distinct sum

Evaluate: For each record

Reset: Never

Try and check if it works. I dont have crystal report but i just tried to recalled what i did earlier

Upvotes: 2

campagnolo_1
campagnolo_1

Reputation: 2750

Use a Running Total which sums value, but only evaluates on change of ID and doesn't reset.

Upvotes: 1

Related Questions