Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to concatenate ? 1

Status
Not open for further replies.

CrystalReports9

Programmer
Jan 10, 2003
124
US
in the detail section i have to concatenate fields together by validating another column's value(in the same detail section.)

<Detail Section>

C1 C2
-- ---
1 A1
1 A2
1 A3

2 B1
2 B2

Here concatenation to be done until the column c1 values get changed.

Output to be like ...

<Detail Section>

C1 C2
-- ---
1 A1-A2-A3
2 B1-B2
 
Create three formulas:

//{@reset} to be placed in the group header:
whileprintingrecords;
stringvar x;
if not inrepeatedgroupheader then
x := "";

//{@accum} to be placed in the detail section:
whileprintingrecords;
stringvar x := x + {table.C2} + "-";

//{@display} to be placed in the group footer:
whileprintingrecords;
stringvar x;
left(x,len(x)-1);

-LB
 
Lbass forgot to mention that you should group by the C1 column.

Not sure why you need an inrepeatedgroupheader function though, try using:

//{@reset} to be placed in the group header:
whileprintingrecords;
stringvar x:="";

//{@accum} to be placed in the detail section:
whileprintingrecords;
stringvar x := x + {table.C2} + "-";

//{@display} to be placed in the group footer:
whileprintingrecords;
stringvar x;
left(x,len(x)-1);

-k
 
i have to concatenate only the deatil section data, not related to the groupheader values.

C1 and C2 both are in the <detail section>

In the detail i am getting like
----------------------------------
A1-
A1-A2-
A1-A2-A3

Instead of 3 rows is it possible to get a single value
A1-A2-A3 within the <detail section>
 
You need to suppress the details section and only display the group footer.

SV-Yes, I assumed there was a group on C1.

I was alerted to the need for the not inrepeatedgroupheader clause by someone who regularly reads my posts and noted that I always seemed to leave it out. Without the clause, the reset formula will reset on a new page for the same group, if the group is formatted to "repeat group header on each page".

-LB
 
Without the grouping can't i get the result, within the detail section ? :(
 
No, but why does it matter? Please explain in more detail.

-LB
 
Hmmm, interesting, and it makes sense programmatically if you have explicitly stated to repeat the group header on each page.

To complicate things a tad though, I just tested it in CR XI and if only a group footer expands to the next page the repeated group header doesn't display/fire. It only does so while the details or the group header are continuing. Seems a small buglet, but nonetheless it does not repeat the group header on the next page if only the group footer is continuing from the previous page.

I suggest that the three formula method should be constructed using a display in the groupfooter, then a reset in a subsequent group footer to simplify and minimize code.

Thanks for pointing this out, *LB*!

Here's an old whitepaper on the topic suggesting the 2 workarounds if anyone is interested:

0 6074568

-k
 
In the detail i have few more columns like C3, C4. So i cann't suppress the <detail section>. i have to concatenate only C2 based on the C1.

<Group Section> Roll Number: 10

<Detail Section>
C1 C2 C3 C4
-- -------- ------- ----
1 A1-A2-A3 N3-B1 100
2 B1-B2 N5 200
 
Please post all of your requirements in their entirety up front, you waste other peoples time because you didn't want to take the time to do so.

Anyway, you cannot display what is in record 10 of C2 while displaying what is in record 2 of C3 if C3 is not to be concatenated.

So you'll need a subreport to go get everything in C2 and concatenate it and return it in a shared variable.

Curious why your example of C3 indicates that it has a display as if it had been concatentaed, but that's what is currently showing without concatenating?

I think that you should post example data for all fields and then what you expect as the output.

-k
 
i have to concatenate only two columns namely c1 and c2. Not other columns

Rule:
concatenate C2 based on the C1 value.
Whenever C1 value get changed until then concatenate C2.
This concatenation not related to the Group columns value.
No need to think about C3 and C4 columns
-----------------------------------------------------------

SAMPLE DATA
-------------
<Group Section> Roll Number: 10

<Detail Section>

C1 C2 C3 C4
-- --- ---- ----
1 A1 N3-B1 100
1 A2
1 A3
2 B1 N5 200
2 B2

<Group Section> Roll Number: 11

<Detail Section>

C1 C2 C3 C4
-- --- ---- ----
3 C1 NB 120
3 C2
3 C3
4 D1 AD1 40
4 D2
----------------------------------------------------------
OUTPUT (REQUIRED)
--------------------------
<Group Section> Roll Number: 10

<Detail Section>
C1 C2 C3 C4
-- -------- ------- ----
1 A1-A2-A3 N3-B1 100
2 B1-B2 N5 200

<Group Section> Roll Number: 11

<Detail Section>
C1 C2 C3 C4
-- -------- ------- ----
3 C1-C2-C3 NB 100
4 D1-D2 AD1 40
 
If you did as previously suggested in terms of grouping by the C1 column and the 3 formula method, then just add in 2 formulas for the C3 and C4 of:

maximum({c3},{c1})

maximum({c4},{c1})

Place these in the same group footer of column C1.

-k
 
If C3 and C4 are null for some rows, then just right click on each and insert a maximum on each at the group level. If C3 and C4 actually repeat for each row and you just are showing the fields after suppressing for duplication, you could just drag the fields into the group footer.

-LB
 
Still not get the expected results.

Objective:
------------
Concatenate only two columns(like c1,c2) in the detail section

Rule:
-------
This concatenation not related to the Group columns value.
This concatenation not related to other columns like C3 and C4 in the above example.
Not supress the Detail section
No new group level to added along with the existing group.

Thanks for all your suggestion. THanks

 
Where are these rules coming from? If the data exists only in different rows, you will have to use a group section.

You can get the desired display without relying on the detail section. Please show sample data at the detail level without any field or section suppression and then show how you would the results to look.

-LB
 
The meaning for the 'RULE' is 'CONDITION'/'CONSIDERATION'/'LIMITATION'.

The following OUTPUT should be achived within the <detail section>. Also No need to think about 3rd and 4th columns values.

SAMPLE DATA <Detail Section>
----------------------
1 A1 N3B1 100
1 A2
1 A3
2 B1 N5 200
2 B2

OUTPUT (required)
-----------------------
1 A1-A2-A3 N3B1 100
2 B1-B2 N5 200

Thank you for the HELP
 
My earlier suggestions will give you this result. Insert a group, use the three-formula method, and insert maximums on the other two fields at the group level. Then suppress the detail section. There is no way to do this within the detail section.

-LB
 
Question for lbass (and SV) regarding previous comment:

"I was alerted to the need for the not inrepeatedgroupheader clause by someone who regularly reads my posts and noted that I always seemed to leave it out. Without the clause, the reset formula will reset on a new page for the same group, if the group is formatted to "repeat group header on each page"."

Is there some reason why the reset should not be placed in the group footer? I've been putting it there since my first usage of this technique (it was introduced to me as a "manual running total" by a Crystal instructor about 4 years ago) and I've never had a problem with the sums. Seems that group footer placement would prevent the potential problem with "repeated group header."
 
Sure, you can do that, but you would have to then insert another group footer section below the one containing the display formula. Either way works.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top