Print Page | Close Window

Concat multiple values of same field on 1 detail

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=14032
Printed Date: 03 May 2024 at 3:30pm


Topic: Concat multiple values of same field on 1 detail
Posted By: jimbo79
Subject: Concat multiple values of same field on 1 detail
Date Posted: 11 Aug 2011 at 1:06am
Table 1       Table 2
1               1      a
2               1      b
3               1      c

I want to concatenate a b c onto a single details line for the value in Table 1.

This is as far as I got but the array only ever returns 1 value and so the loop never works.


    Dim arrTestodes
    arrTestodes = array({Table2.Column2})

    Dim i
    Dim stringoftests
    i = 1

    Do while i <= ubound(arrTestodes)
        if i < 2 then
            stringoftests = totext(arrTestodes(i))
        else
            stringoftests = stringoftests + ", " + ToText(arrTestodes(i))
        end if
    i = i + 1
    Loop
    formula = stringoftests


Where am I going wrong?



Replies:
Posted By: lockwelle
Date Posted: 11 Aug 2011 at 3:22am
since when you join the tables, there is are still 3 rows in the resulting table that CR sees, and CR only reads 1 row at a time, it doesn't see that there are 3 related items (well not in the detail section)
 
you can concatenate if you put the output in a group footer, since CR will have read all 3 records by that time.  3 formulas are usually needed
1) header - reset
shared stringvar concat := ""
2) footer - display
shared stringvar concat;
mid(concat, 3)   //removes the leading comma and space
3) detail - increment
shared stringvar concat;
concat := concat + ", " + {table.field};
""   //hides the growing string
 
HTH


Posted By: jimbo79
Date Posted: 11 Aug 2011 at 4:37am
Thanks very much for the respnse.

Please can you add a bit more meat to your answer, I'm not 100% on what I need to do.

Thanks

James :-)


Posted By: jiangjiang
Date Posted: 14 Aug 2011 at 5:44pm
cheerful and most looking kid as one of the gang with all pals. http://www.onedreamwed.com - Party Dresses uk If you're shopping with junior clothesin larger sizes then it could be prudent that you want flare jeans or bell-bottoms and it will indeed become a wise choice to have the kiddo appear voguish. http://www.onedreamwed.com - Wedding Dresses store Additionally, make sure that you've got some black, as they may last 


Posted By: Cassal Services
Date Posted: 15 Aug 2011 at 3:03am

If your data is coming sorted with groupings, you can use the "NEXT" function in a formula.  

If NEXT{matching-field} = {matching-field} Then {OutputField}
 
The NEXT or PREVIOUS function allows you to look at the record just after or just before, and then make a decision to concatenate the next record into your output formula field.


Posted By: GJUFFER
Date Posted: 04 Nov 2011 at 3:02pm
Suppose you have data that looks like this:

1     -     Rose
2     -     Violet
3     -     Rose
4     -     Tulip

Is there a way to concatenate the second column as shown above and also remove the duplicate strings?  My data source needs to be in sequential order, so suppress if duplicated is not an option.



Print Page | Close Window