Concatenate Text Field across from Rows into a single field

Wow! This has just solved a really annoying problem for me. I have a requirement to produce a branch/centre listing from live data (so it is an on demand real time report). As such building the data in the required format via SSIS is not an option. Also, we do not generally report against live data in this way, so it is also not appropriate to build it into an existing universe. Unusually, freehand SQL is the way forward for this.

Each branch centre can have notes entered against it. But these are stored in a separate table like this:
Code
LineNo
Comment

The comment field is only 80 characters long. Any comments that require more than this are spread over multiple records with incremental line numbers. It would appear that when these notes are entered, continuous typing is automatically split onto a new record, as the records can break halfway through a word.

As such, what I needed to do was to concatenate all comments from an unknown number of records into a single string, without any delimiter. I did find a way to do this in the SQL code using recursive common table expressions. However, Business Objects didn’t like this at all.

After trying lots of different things and doing lots of searching I stumbled across this thread, which has given me my solution…

Keeping the separate freehand SQL query for the comments, which brings in each individual record, all I needed to do was define the “Comment” field (via the Data Manager) as a measure which is aggregated with SUM. Now, if I bring in the “Comment” measure at the “Code” level it is concatenated exactly as required.

This is perfect for me. Thank you very much. :smiley:

I can see that this is a very old thread, and either you found a solution or it is no longer an issue, but if you are pulling your data from a defined universe, then I wonder if the post by reemagupta on page 2 of the following thread is/was the solution for your problem…
https://bobj-board.org/t/19613


SHardy :uk: (BOB member since 2006-04-05)