Author |
Message |
mdmendoza
Newbie
Joined: 20 Feb 2008
Location: Philippines
Online Status: Offline
Posts: 8
|
Topic: concatenate rows Posted: 20 Feb 2008 at 8:43pm |
does anyone knows how to concatenate rows into 1?
example:
ID No Name Time In 1 Greg 9:00 1 Greg 10:00 2 Vince 9:30 3 Tom 6:00
i expect to have this result:
ID No Name Time In
1 Greg 9:00,10:00
2 Vince 9:30
3 Tom 6:00
thnx!
|
IP Logged |
|
hilfy
Admin Group
Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
|
Posted: 21 Feb 2008 at 6:22am |
This should work.
In your report, group on name or id number (whichever order you want your data to appear.)
Create a formula called TimeIn:
Stringvar TimeIn;
if previousIsNull({table.groupfield}) or ({table.groupfield} <> previous({table.groupfield})) then
TimeIn := {table.TimeInField};
else
TimeIn = TimeIn + ", " + {table.TimeInField};
TimeIn
If TimeIn is not a string field, you'll need to convert it to a string in your formula.
You then setup your data in the group footer using the formula instead of the field.
-Dell
|
|
IP Logged |
|
mdmendoza
Newbie
Joined: 20 Feb 2008
Location: Philippines
Online Status: Offline
Posts: 8
|
Posted: 21 Feb 2008 at 4:41pm |
the else function is highlighted and gives an error message of "The remaining text does not appear to be a part of the formula."
|
IP Logged |
|
BrianBischof
Admin Group
Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
|
Posted: 21 Feb 2008 at 5:03pm |
Remove the semi-colon from the line right before it.
|
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>
|
IP Logged |
|
mdmendoza
Newbie
Joined: 20 Feb 2008
Location: Philippines
Online Status: Offline
Posts: 8
|
Posted: 21 Feb 2008 at 6:03pm |
@BrianBischof
thx for the help... now i dont have errors.
BUT the output seems to have a problem... it doesn't show both time
|
IP Logged |
|
BrianBischof
Admin Group
Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
|
Posted: 21 Feb 2008 at 6:10pm |
which time does it show? The first one or the last one?
|
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>
|
IP Logged |
|
mdmendoza
Newbie
Joined: 20 Feb 2008
Location: Philippines
Online Status: Offline
Posts: 8
|
Posted: 21 Feb 2008 at 7:24pm |
it shows the second time of the employee with 2 time logs... how can i show the first time?
|
IP Logged |
|
BrianBischof
Admin Group
Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
|
Posted: 21 Feb 2008 at 7:29pm |
Well, try this instead. In the group header, reset TimeIn to "". Global StringVar TimeIn := ""; Then in the Details section use the formula Global StringVar TimeIn; TimeIn = TimeIn + ", " + {table.TimeInField};
|
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>
|
IP Logged |
|
mdmendoza
Newbie
Joined: 20 Feb 2008
Location: Philippines
Online Status: Offline
Posts: 8
|
Posted: 21 Feb 2008 at 9:44pm |
the first formula u told me worked... but the problem is, the output looked like this:
ID No Name Time In
1 Greg 9:00
1 Greg 9:00,10:00
2 Vince 9:30
3 Tom 6:00
instead of:
ID No Name Time In 1 Greg 9:00,10:00
2 Vince 9:30
3 Tom 6:00
thx again..
Edited by mdmendoza - 21 Feb 2008 at 9:47pm
|
IP Logged |
|
BrianBischof
Admin Group
Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
|
Posted: 21 Feb 2008 at 10:28pm |
Ah, I see. You need to put your data in the group footer section instead of the Details section. Dell mentioned it at the end, but I guess it wasn't clear enough. And you need to hide the Details section so that you only see the Group Footer. Give it a try and let me know if that worked for you.
|
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>
|
IP Logged |
|
|