Split function or easier way?
Printed From: Crystal Reports Book — Forum Name: Technical Questions
Posted By: veg_racer — 9 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?
Posted By: kevlray — 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.
Posted By: Valert16 — 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}, ","))
Posted By: veg_racer — 17 Feb 2021 at 1:07am
Seems to work perfectly! Thank you very much!
|