Print Page | Close Window

SPLIT

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=22688
Printed Date: 28 Mar 2024 at 2:59am


Topic: SPLIT
Posted By: BostonRedHead
Subject: SPLIT
Date 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



Replies:
Posted By: DBlank
Date 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];


Posted By: BostonRedHead
Date 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



Print Page | Close Window