Print Page | Close Window

Creating a concatenated String

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=3689
Printed Date: 19 May 2024 at 5:07am


Topic: Creating a concatenated String
Posted By: zyberjock
Subject: Creating a concatenated String
Date Posted: 13 Jul 2008 at 7:28pm
i have data with this display format as displayed by cr9
From     TimeTo       Day

8:00     10:00         M
8:00     10:00         W
9:00     11:00         F


and what would i do so that it would end up like this
From     TimeTo      Day

8:00     10:00        MW
9:00     11:00        F

Thanks and more power



Replies:
Posted By: zyberjock
Date Posted: 13 Jul 2008 at 9:28pm
is there a way to do that???Cry


Posted By: venkatesha
Date Posted: 13 Jul 2008 at 10:46pm
Create  groups for From and Time To. Place these group name in Group 2 Footer.

Create three formulas   
     1.  DeclareField  formula
       WhilePrintingRecords;
        stringVar str:="";
     Place the same in Group 1 header.
   
    2. ConcatenateField formula  the field in the detail section by using the formula

           WhilePrintingRecords;
            stringVar str;
            str:=str+ {Sheet5_.Day};
    
   3.  DisplayDay formula Place the field in Group2

    WhilePrintingRecords;
    stringVar str;
     str;


Posted By: zyberjock
Date Posted: 14 Jul 2008 at 5:38pm
thanks it's working fine now Clap


Posted By: elamantia
Date Posted: 20 Aug 2008 at 5:05pm

To continue on with this same scenario... What if your data was

From     TimeTo       Day

8:00     10:00         M
8:00     10:00         M
8:00     10:00         M
8:00     10:00         W
9:00     11:00         F
How would you stop the report from duplicating the three M's like below?:
 
8:00     10:00      MMMW
9:00     11:00      F
 
I have been trying to figure this out for awhile!!Confused
 
Thanks for your help!


-------------
minnie_eye


Posted By: BrianBischof
Date Posted: 20 Aug 2008 at 5:23pm
You can do one of two things. The first is use the PreviousValue() function to see if the current value equals the previous value, and if so then don't do the concatenation. The other option is to see if the last character in the string doesn't match the current value and then do the concatenation. use the same code in the previous post, but add a condtional statement before it.
 
option 1:
if {Sheet5_.Day} <> PreviousValue({Sheet5_.Day}) Then
    str:=str+ {Sheet5_.Day};
option 2:
if Right(str,1) <> {Sheet5_.Day} then
    str:=str+ {Sheet5_.Day};

 

I have all the Crystal syntax formulas and sample code for how to use them in three chapters of my Encyclopedia book. You can find out more about my books at http://www.amazon.com/exec/obidos/ASIN/0974953601/bischofsystem-20 - Amazon.com or reading the http://members.crystalreportsbook.com - Crystal Reports eBooks online.




-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>


Posted By: elamantia
Date Posted: 21 Aug 2008 at 7:42am
That eliminated most of my duplicates.  But there is one more complication.  If the data is listed as below:
8:00     10:00         M
8:00     10:00         M
8:00     10:00         M
8:00     10:00         W
8:00     10:00         M
8:00     10:00         W
9:00     11:00         F
How would you stop it from showing:
 
8:00      10:00       MWMW
9:00      11:00       F
 
Since the comparison is to the immediate previous field it will still duplicate.
Thanks!!


-------------
minnie_eye



Print Page | Close Window