Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: SPLIT Post Reply Post New Topic
Author Message
BostonRedHead
Newbie
Newbie


Joined: 31 Oct 2018
Location: United States
Online Status: Offline
Posts: 2
Quote BostonRedHead Replybullet Topic: SPLIT
    Posted: 01 Nov 2018 at 5:33am
I have a field where the data output looks like this:

DESCRIPTION
RW/MS/SCRAP/BOSTON

I need to separate each value between the forward slashes into its own field like this:

DESC1 DESC2    DESC3    DESC4
   RW     MS       SCRAP    BOSTON

I found the following formula online and placed it in DESC1. It works great.

If not Isnull({INVENTORY_TRANS.DESCRIPTION}) then
If Instr({INVENTORY_TRANS.DESCRIPTION}, "/") >1 Then Mid({INVENTORY_TRANS.DESCRIPTION} , 1, (INSTR({INVENTORY_TRANS.DESCRIPTION} , "/")-1)) else { INVENTORY_TRANS.DESCRIPTION}

However, if I replicate the formula and place it in DESC2, DESC3 & DESC4, making what I thought were the necessary adjustments, it doesn't work.

Here is how I adjusted them (which I am sure I am TOTALLY off the mark!):

DESC2
If not Isnull({INVENTORY_TRANS.DESCRIPTION}) then
If Instr({INVENTORY_TRANS.DESCRIPTION}, "/") >2 Then Mid({INVENTORY_TRANS.DESCRIPTION} , 2, (INSTR({INVENTORY_TRANS.DESCRIPTION} , "/")-2)) else { INVENTORY_TRANS.DESCRIPTION}

DESC3
If not Isnull({INVENTORY_TRANS.DESCRIPTION}) then
If Instr({INVENTORY_TRANS.DESCRIPTION}, "/") >3 Then Mid({INVENTORY_TRANS.DESCRIPTION} , 3, (INSTR({INVENTORY_TRANS.DESCRIPTION} , "/")-3)) else { INVENTORY_TRANS.DESCRIPTION}

DESC4
If not Isnull({INVENTORY_TRANS.DESCRIPTION}) then
If Instr({INVENTORY_TRANS.DESCRIPTION}, "/") >4 Then Mid({INVENTORY_TRANS.DESCRIPTION} , 4, (INSTR({INVENTORY_TRANS.DESCRIPTION} , "/")-4)) else { INVENTORY_TRANS.DESCRIPTION}

Can someone please help me with the needed adjustments?

Much appreciated!
Trust The Redhead
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 05 Nov 2018 at 2:43am
are there always 4 values separated by "/"?
you can create 4 formulas using the split

Local StringVar desc1;
desc1:=split({INVENTORY_TRANS.DESCRIPTION},'/')[1];
IP IP Logged
BostonRedHead
Newbie
Newbie


Joined: 31 Oct 2018
Location: United States
Online Status: Offline
Posts: 2
Quote BostonRedHead Replybullet Posted: 05 Nov 2018 at 11:28am
Sometimes only 3, but I have placeholders (fields: DESC1, DESC2, DESC3, DESC4) for up to 4 values.

Like I mentioned above, I found a formula online which I used. It handles the value before the first "/" just fine, but I can't get it to work past that since I don't truly understand the formula. I do not know how to adjust the variables correctly (see above where I simply adjusted the numbers in the formula to reflect 1, 2, 3 and 4...which I clearly isn't accurate).
Trust The Redhead
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.015 seconds.