Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: comparing data on 3 or more lines of data Post Reply Post New Topic
Author Message
ct_mike
Newbie
Newbie


Joined: 10 Oct 2016
Online Status: Offline
Posts: 1
Quote ct_mike Replybullet Topic: comparing data on 3 or more lines of data
    Posted: 21 Oct 2016 at 8:50am

if the serviceid, client and date are the same but the crew name is different, I want to be able to assign a % to the amount of work a multi person crew does for the service id. The only thing I could accomplish was to read, count and calculate 2 lines of data. I cannot get it to compare and calculate more than 2 lines of data.

Here is what the results should look like (the job % column is the results I am looking for) -

client

SvcID

crew name

date

Job %

q

123

abc

10/1/2016

33%

q

123

def

10/1/2016

33%

q

123

jkl

10/1/2016

33%

q

456

qwe

10/1/2016

100%

q

321

sdf

10/1/2016

100%

w

753

tyu

10/1/2016

50%

w

753

poi

10/1/2016

50%

w

951

qwe

10/1/2016

100%

o

654

abc

10/1/2016

33%

o

654

def

10/1/2016

33%

o

654

jkl

10/1/2016

33%

o

369

fgh

10/1/2016

100%

o

369

fgh

10/1/2016

100%

o

147

fgh

10/1/2016

100%

 

I have use 'next record' and 'previous record' commands as well as 'onfirstrecord' and 'onlastrecord' commands. I've also tried loops. Here is the formula I am currently using.

Shared Numbervar c;// counts the number of serviceids with different crews c:=1; If ( onlastrecord or {Command.ServiceId}= next({Command.ServiceId}) and {Command.CrewName} = next({Command.CrewName}) and {@Date} =

next({@Date})  //the Date formula is date({Command.OutDateTime})

)

or  (

{Command.ServiceId}<> next({Command.ServiceId})

)

Then

(

c:=c+0

)

Else

If (

{Command.ServiceId}=next({Command.ServiceId})

and  {Command.CrewName} <> next({Command.CrewName})

)

Then

(

c:=c+1

);

1/c;

IP IP Logged
Valert16
Groupie
Groupie
Avatar

Joined: 21 Mar 2016
Location: Spain
Online Status: Offline
Posts: 57
Quote Valert16 Replybullet Posted: 23 Oct 2016 at 11:49pm
I think your best solution is group your records by date, client and serviceid. So you'll create three groups.
Being servideid the deepest group, insert a summary for it. Use the field crew and choose Distinct Count as operation.
Create formula JobPercent with this code:
     100 / DistinctCount ({TableName.crew}, {TableName.SvcID})
Put the JobPercent formula in the detail section and hide all group sections you don't want to see.
The inconvenient is that this will show records ordered by date, client and crew, wich may differ from the original order.
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.031 seconds.