Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Number sequences Post Reply Post New Topic
Author Message
penilsso
Newbie
Newbie


Joined: 08 Dec 2009
Location: Denmark
Online Status: Offline
Posts: 1
Quote penilsso Replybullet Topic: Number sequences
     Posted: 27 Oct 2012 at 3:21am
Hi all

I have a question regarding grouping and presenting results.
We have a table with results for a specified lab analysis and we would like to group the results instead of showing each detail.
Lets say we have the following:

Sample number        Result
1                              Negative
2                              Negative
3                              Negative
4                              Positive
5                              Negative
6                              Positive
7                              Positive
8                              Negative
9                              Negative
10                            Negative

We would like this to be presented like:

Result: Negative      Samples: 1-3,5,8-10

Result: Positive        Samples: 4, 6-7

Any ideas on how to solve this?

Thanks in advance
Peter Nilsson


Edited by penilsso - 27 Oct 2012 at 3:22am
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 29 Oct 2012 at 5:09am

I haven't tried this, but you might be able to do something like this:

1. Group your data by Result.
2. Create a formula that looks something like this:
StringVar samples;
NumberVar sampleNum;
BooleanVar isRange;

//Initialize the variables at the beginning and on change of status.
if PreviousIsNull({MyTable.Result}) or {MyTable.Result} <> previous{MyTable.Result} then
(
   samples := 'Samples:  ';
   sampleNum := 0;
   isRange := false;
)
 
if sampleNum > 0 and {MyTable.SampleNum} > sampleNum + 1
  if isRange then
    samples := samples + '-' + ToText(sampleNum, 0, '') + ',' + ToText({myTable.SampleNum}, 0, '')
  else
      samples := samples + '-' + ToText({MyTable.SampleNum}, 0, '');
else if sampleNum = 0 then
  samples := samples + ToText({MyTable.SampleNum}, 0, '');
 
sampleNum := {MyTable.SampleNum};
 
samples
 
Like I said, I haven't tested this yet, but hopefully it will get you started.
-Dell
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