Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Display list horizontally Post Reply Post New Topic
Page  of 2 Next >>
Author Message
judylynn
Newbie
Newbie
Avatar

Joined: 17 Nov 2008
Location: United States
Online Status: Offline
Posts: 22
Quote judylynn Replybullet Topic: Display list horizontally
     Posted: 31 Jan 2013 at 5:19am
I would like to display a list of enrolled programs horizontally for each household. For example:
 
Family ID     Enrolled Programs
 
12                  A, B, C, D
20                 J, K, B, C
25                  D, A
33                 K
45                 P, A, G
 
My data is coming from an Excel sheet with multiple records for each Family ID (one record per Enrolled Program).
 
I tried this formula, and it works for just two programs but displays only up to two:
 
If {Sheet1_.Family ID}= (Previous ({Sheet1_.Family ID}))then ({Sheet1_.Enroll Program}+ ", " + previous ({Sheet1_.Enroll Program})) else {Sheet1_.Enroll Program}
 
 
Please advise the best way to do this! I know I saw a post
 with a solution a while back but I cannot find it!
Thanks...
 
 


Edited by judylynn - 31 Jan 2013 at 8:38am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 31 Jan 2013 at 12:01pm
IP IP Logged
judylynn
Newbie
Newbie
Avatar

Joined: 17 Nov 2008
Location: United States
Online Status: Offline
Posts: 22
Quote judylynn Replybullet Posted: 01 Feb 2013 at 3:52am
Thanks! That works great - my only problem now is that I get the comma at the end of the list. This is my formula in Details section:
 
Whileprintingrecords;
Stringvar flag:= flag + (if instr(Stringvar flag,{Sheet1_.Enroll Program}) > 0 then " " else {Sheet1_.Enroll Program} + (', '))
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 01 Feb 2013 at 4:06am
if yo do not have duplicates inside each group you do not need to use the instr() function on it
for you final display formula you can trim the last character
Stringvar flag:= left(flag,len(flag)-1)
IP IP Logged
judylynn
Newbie
Newbie
Avatar

Joined: 17 Nov 2008
Location: United States
Online Status: Offline
Posts: 22
Quote judylynn Replybullet Posted: 01 Feb 2013 at 4:16am
I don't have duplicates, but the list can be one or several items. I wasn't sure about the instr() function, so I put it in. It works fine for me without it.
 
Whileprintingrecords;
Stringvar flag:= flag + {Sheet1_.Enroll Program} + (', ')
 
How would I incorporate this part so that it only trims off the comma on the last record?
 
Stringvar flag:= left(flag,len(flag)-1)

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 01 Feb 2013 at 4:54am

are you resetiing this for a group?

IP IP Logged
judylynn
Newbie
Newbie
Avatar

Joined: 17 Nov 2008
Location: United States
Online Status: Offline
Posts: 22
Quote judylynn Replybullet Posted: 01 Feb 2013 at 6:30am
Yes, I have a group on Family ID and have formulas in the header and footer as in your example.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 01 Feb 2013 at 7:29am

so you need 3 formula's

changes your formula to use a shared stingvar
1 initializes and sets teh stringvar to =""and is in the gheader
the next sgets each value from each row in teh detail section (the formual you are now using
the third is used to dsiplay teh final result and goes in the gf, this is where you set the shared stringvar flag value to to = left(flag(len(flag))
IP IP Logged
judylynn
Newbie
Newbie
Avatar

Joined: 17 Nov 2008
Location: United States
Online Status: Offline
Posts: 22
Quote judylynn Replybullet Posted: 04 Feb 2013 at 3:47am
It's working, but still not trimming off the last comma. This is what I have in the footer:
 
WhilePrinting Records;
Shared  StringVAr flag:= left(flag,len(flag)-1);
Shared StringVar flag
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 04 Feb 2013 at 7:54am
you are adding a comma and a space aren't you?
subtract 2 characters instead of 1.
 
 
WhilePrinting Records;
Shared  StringVAr flag:= left(flag,len(flag)-2);
Shared StringVar flag
IP IP Logged
Page  of 2 Next >>
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum