on 10-19-2011 4:12 PM
I have description field in the database and I need to concatenate the value of the filed into one line. How to do that? I tried as below
Stringvar strtitle="";
whilereadingrecords;
if Mid({OrderDtl.PartNum},1,2)="T3" Then
strtitle & "T3- Background Music,"
Else if Mid({OrderDtl.PartNum},1,2)="T6" then
strtitle & "T6- Dance"
This is not working and showing only last value instead of concatenated string. I am very new to Crystal report and i am using Crystal report 2008
Thanks,
Raj
Hello,
Try this
In one formula you'd have this -
Global Stringvar strtitle="";
whilereadingrecords;
if Mid({OrderDtl.PartNum},1,2)="T3" Then
strtitle & "T3- Background Music,"
Else if Mid({OrderDtl.PartNum},1,2)="T6" then
strtitle & "T6- Dance"
Place this formula in the detail section and surpress it
Create another formula and have this
WhileReadingRecords;
Global StringVar StrTitle;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the reply.
I need this formula to put in the Report footer and cannot put it in the detail section. Even If I use this in the details section and set the suppress for duplicates, it prints one by one; NOT in one single line. I need all the values concatenated into one single line.
Hi Raj,
I guess you're trying to concatenate the descriptions so that they appear on a single line, perhaps, on the report footer?
Try this formula:
whilereadingrecords;
stringvar strtitle;
strtitle := strtitle + ">" + {description_field_from_database}
The ">" sign is to separate the records from each other; you may choose to remove this from the formula or use another separator.
Place the above formula in the details section and suppress the section.
Create this formula to display the result and place it in the Report Footer section:
evaluateafter(@Name_of_the_above_formula);
stringvar strtitle;
Let me know how this goes!
-Abhilash
My requirement is becomding weid now...
'T3', 'T6' are Tariff names to apply for the customer. If I see one of each (T3 and T5) or both, then I should stop running the loop
Like below
"T3- Background Music, T6- Dance' though there are more than 100 lines.
However, now it is printing like below
"T3- Background Music, T6- Dance> T3- Background Music, T6- Dance> T3- Background Music, T6- Dance'' because there are 6 records in the table (3 sets of T3 and T6 tariffs)
Am I confusing ?
Hi Raj,
The value assignment is done in this way: stringvar strtitle := "";. You're missing the colon sign (:).
In the formula you've assigned/you're trying to assign strtitle a blank value. Since strtitle is blank, this code:
if Mid({OrderDtl.PartNum},1,2)="T3" Then
strtitle & "T3- Background Music,"
Else if Mid({OrderDtl.PartNum},1,2)="T6" then
strtitle & "T6- Dance"
will always return either T3- Background Music, or T6- Dance.
If you're trying to prefix a string before "T3- Background Music," then you would need to assign something to the strtitle variable.
Hope this helps!
-Abhilash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Abhilash,
I am trying to sort me report based on several field formulas. I have several formulas because I want a blank to appear if value is "" but a word to appear if value is "1". For example, one of my formulas is: if {Daily_Flash_Report_for_Crystal.Peak?}="1" then "Peak" else "". I need each formula where the words are the same to be grouped together. For example my rpoet layout is:
Group 1: Sales Rep Location
Group 2: Sales Rep
Account name Target/Peak/Focus
I want to be able to see all of my "Peak" accounts at the top of the page group, the focus, then target, then blanks.
I am failing at using a parameter. Do you have any suggestions?
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.