Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Splitting Record in 3 groups 1

Status
Not open for further replies.

PacinoQS

Technical User
Mar 2, 2008
26
NL
Hello,
I am trying to make a pricelist in Crystal Reports.
In my report I want to show the article name - packaging - brand. Unfortunately I have all those information in 1 record so I need to find a way to split it.

At the moment my record looks like this:

<Item name> - <Item packacing> / <Brand>

I tried making a formula with the split function but it gives me the error that it cant result an array in the report.

Anybody has some advice for me?
 
You didn't create my formulas correctly. For some reason, you switched the order of "-" and "/", when you shouldn't have. Go back to my initial formulas and use them. Also, in my formulas, I built in the spaces around the hyphen and slash as you showed them. If there are no spaces in your actual field, then remove them.

These formulas also assume that every record contains a hyphen and a slash. If they don't, or if the field can be null, you need to tell us, so we can adjust for that.

-LB
 
I switched the - and the / because I stated it wrong in the start post. First there is the / and then there is the -. I also removed the spaces around the " cause sometimes they are attacked right to eachother.

Not every record has a hyphen and a slash so that could be the problem. Do I need to add something to the formula?
 
Yes, you do. Please show samples of your field that show the variations that can occur. You should have started out with this.

-LB
 
Lbass , other variations could be :
<item name> / <Brand>
<item name>
<item name> - <packaging>

I need to add some kind of formula where it states that it should display these and all other possible variations under some sort of unsorted group. That way I can add for example the brand and package to the field so it will show in the right group (brand).

 
The usual format that I want to use is <item name> - <packaging> / <brand> but sometimes I dont have all that for an item field. Thats why I think its better to add some formula that if the field isnt complete in that format it will show in another unsorted categorie so I can add that later.
 
So test for it being incomplete and if it is, assign some special value to it.

If <incomplete logic here> then "incomplete" else <current logic here>

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"What version of URGENT!!! are you using?
 
Well, that's the format you originally identified, which you later discounted as being incorrect. Anyway, try this:

//{@groupfield}:
if instr({Items.Description}," - ") > 0 and
instr({Items.Description}," / ") > 0 then
split(split({table.field}," - ")[2]," / ")[2] else
"Other"

Insert a group on {@groupfield}, and then create two formulas for the other components:
//{@itemname}:
if instr({Items.Description}," - ") > 0 then
left({Items.Description},instr({Items.Description}," - ")-1) else
{Items.Description}

//{@packaging}:
if instr({Items.Description}," - ") > 0 and
instr({Items.Description}," / ") > 0 then
split(split({table.field}," - ")[2]," / ")[1] else
{Items.Description}

This will show the correct component unless it doesn't meet your format conditions, in which case it will appear in the "Other" category, with the full field displayed.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top