Crystal Report; Combining data rows into a single value

I have data in rows like this for id 1

id1 a1

id1 b2

id1 c3

id1 d4

id1 e5

I like to combine it as "a1b2c3d4e5" with one value for id1. Thanks in advance.

+6
crystal-reports
source share
3 answers

One approach is the "3 formula" method. You set up the initialization formula in each header, with the "WhilePrintingRecords" evaluation time directive. This approach was the only one available for executing current totals in the “good days” before RunningTotal objects were available.
For example:
In the group header: - have the formula @InitiliseRT

WhilePrintingRecords; StringVar ConcatenatedID; If Not InRepeatedGroupHeader Then ConcatenatedID := ""; 

In the "Details" section: - have the formula @UpdateRT

 WhilePrintingRecords; StringVar ConcatenatedID := ConcatenatedID + id1; 

Finally, in the Footer group you can see the result: - Formula @ShowRT

 WhilePrintingRecords; StringVar ConcatenatedID; 

This should give you the final line "a1b2c3d4e5".

If you need, you can add additional formulas for additional groups, one variable for each group (for example, ConcatenatedIDGroup1, ConcatenatedIDGroup2). The key is to always get the name on the right between the groups and initialize the variable in the group header.
There are restrictions on the use of these formulas. The built-in summary functions (Sum, Max, Count, ...) or RunningTotals cannot use them, and you cannot group them.

+13
source share

So you want to combine data from several rows into one row for display? Crystal Reports is really not built for this kind of thing. Even if you could, I would still suggest first making this server side and then uploading it to Crystal.

It will not be too difficult, a simple cycle through the data in your chosen language. But Crystal is designed to display and format data using a decent (but not extensive) set of data processing tools. I do not think this is the best way to go.

0
source share

This will depend on the data type for columns a1-e5 and what you are trying to do with a single value.

If you are just trying to display this value, you can create a formula that uses the Crystal ToText () function to first convert them to strings, and then combine them together using "+".

ToText({id1.a1}) + ToText({id1.b2}) + ToText({id1.c3}) + ToText({id1.d4}) + ToText({id1.e5})

You can also do the same on the DBMS side.

If you can provide more information, we can find the best solution.

-one
source share

All Articles