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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to split a string into 3 parts

Status
Not open for further replies.

wanzek1

Technical User
Jun 13, 2012
79
US
I need to split a string into 3 different parts. Below are some examples of the data:

1004. .
1004. 7.276
70003. . 5
71345.7.276
71345. .2

I would like the data to be split at the decimal point. For example:

1004.7.276 would be
1004.
7.
276

70003. . 5 would be
70003.
.
5

Also, if anyone would know of a way to "roll up" so the string that all started with 1004 would be listed once instead of all listed. That would be great.

Thanks!
 
The simplest way would be by way of the Split function using the '.' as the delimiter.

The indiviual elements would be extracted with:

[Code 1stElement]
Split({Table.Field}, '.')[1] + '.'
[/Code]

[Code 2ndElement]
Split({Table.Field}, '.')[2] + '.'
[/Code]

[Code 3rdElement]
Split({Table.Field}, '.')[3] + '.'
[/Code]

These could be concatenated into a single result over multiple lines as follows (making sure to tick the "Can Grow" box in the Format Field area):

Code:
Split({Table.Field}, '.')[1] + '.' + CHR(13)
Split({Table.Field}, '.')[2] + '.' + CHR(13)
Split({Table.Field}, '.')[3] + '.'

You could group the results on the 1st Element formula above if needed.

Hope this helps
Pete

 
Sorry, the last formula should have been:

Code:
Split({Table.Field}, '.')[1] + '.' + CHR(13) +
Split({Table.Field}, '.')[2] + '.' + CHR(13) +
Split({Table.Field}, '.')[3] + '.'

Pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top