Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Split function or easier way? Post Reply Post New Topic
Author Message
veg_racer
Newbie
Newbie
Avatar

Joined: 14 Sep 2015
Online Status: Offline
Posts: 3
Quote veg_racer Replybullet Topic: Split function or easier way?
    Posted: 09 Feb 2021 at 1:13am
Hi Hive brain,

I have a string field that can be a number of values separated by a comma e.g

CAT, DOG, HORSE
CAT, HORSE
HORSE
HORSE, DOG, HAMSTER
I may also have a Null value here

What I would like to do is count the number of values e.g

CAT, DOG, HORSE = 3
CAT, HORSE = 2
HORSE = 1
HORSE, DOG, HAMSTER = 3
I may also have a Null value here = 0

Thats all I need, I don't really need an array of the values, I just need to know how many values there are. I've started down the "Split" function route but I can't seem to get what I want, is there an easier way?
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 16 Feb 2021 at 6:15am
Easier, I do not think so.  It is a parsing problem.  Usually I set up a loop to 'count' each item in the list.  There may be a better solution.  If I have time, I may look into it.
IP IP Logged
Valert16
Groupie
Groupie
Avatar

Joined: 21 Mar 2016
Location: Spain
Online Status: Offline
Posts: 57
Quote Valert16 Replybullet Posted: 17 Feb 2021 at 12:58am
Create a formula using this code (crystal syntax):

If Isnull({Table.StringField}) Then 0 Else Ubound(split({Table.StringField}, ","))
IP IP Logged
veg_racer
Newbie
Newbie
Avatar

Joined: 14 Sep 2015
Online Status: Offline
Posts: 3
Quote veg_racer Replybullet Posted: 17 Feb 2021 at 1:07am
Seems to work perfectly! Thank you very much!
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.063 seconds.