cancel
Showing results for 
Search instead for 
Did you mean: 

How to "sum" or join comments from multiple detail lines?

Former Member
0 Kudos

Hi,

I am creating a report in CR11 where i would like to "sum" all the comments from line items into a single cell or footer.

For example,

The comments in the table could be:

record 1: "load and unload"

record 2: "rig up"

record 3: "march 10 - 12"

I can produce the report with the three line details but I'd rather create a summary that I could join the above comments so that, say, I could put them all one line in the report so it looks like: "load and upload, rig up, march 10 -12".

I tried using the "Insert Summary" function in Crystal however "sum" is not an option when dealing with strings. I can only select "minimum" or "maximum". But I want to select all the comments and join them together. The number of records is not fixed.

Appreciate any help!

thx!

Mark

Accepted Solutions (1)

Accepted Solutions (1)

abhilash_kumar
Active Contributor
0 Kudos

Welcome back Mark!

Here's what you need to do:

Create a formula and place it on the details section:

whileprintingrecords;

stringvar line;

line := line + {database_field} + ", ";

Create another formula and place it on the Report Footer:

whileprintingrecords;

stringvar line;

left(line,len(line)-2);

Let me know how this goes!

-Abhilash

Former Member
0 Kudos

Thanks very much Abhilash!

Mark

Answers (1)

Answers (1)

former_member207611
Active Participant
0 Kudos

Hello Mark:

   You need two different formulas to do this. First formula, place it in Detail section or section where this record is showing, and 2nd in the footer.

   lets assume you have these 3 records in 'Detail' section for simplicity. Write the formulas as below and then drag and drop it in 'Detail section'

//Formula 1, place this in your detail section

WhilePrintingRecords;

StringVar strConcat;

strConcat:=strConcat&", "&{TABLE.FieldName};

strConcat;

//Formula 2, place this in footer where you want this concatenated field to be displayed

WhilePrintingRecords;

StringVar strConcat;

strConcat;

So, basically the formula one will append all the values you see in detail section with comma in between and 2nd Formula in footer displays it as concatenated string. You can suppress the 'detail' formula if you dont want to display it...but it has to be dragged in that section in order to be concateneted for each row...Hope this helps..

Mohammed Imran Alam

http://reportgurus.com/imran

Former Member
0 Kudos

Thanks very much Mohammed!

Mark