Joined: 13 Feb 2012
Location: United States
Online Status: Offline
Posts: 2
Topic: Filter Strings Posted: 13 Feb 2012 at 12:39am
Hello! I'm a new member to the forum and I apologize if this question has been asked before - BUT -
Using Crystal Reports Professional IX
I have an Oracle ODBC database I'm trying to query with Crystal Reports. The particular field I need to extract data from is a string field containing several different pieces of information separated by 'pipes' ( '|' ). The front part of the field contains technician names, so it is always a different length. The back part of the field contains user-entered info, so it is always a different length as well. Because of these different lengths, I can't simply count characters and display the info I need - which is located in the MIDDLE of the string (date-time info). The info is imported from another database, so I can't simply find the desired info in another table.
Is there a way to take the whole string and FILTER the info by counting the number of PIPE ( '|' ) separators? the field contains 6 different types of data all separated by this character, and I'd love to be able to pull out the data between pipes number 3 and 4.
Can this be done?
GregSki
Edited by busy2mch1 - 13 Feb 2012 at 12:46am
To Err is Human - just don't send it to production.
Joined: 20 Dec 2011
Location: England
Online Status: Offline
Posts: 259
Posted: 13 Feb 2012 at 1:16am
Create a formula as follows;
split({table.field},"|")[2]
Change the 2 on the end to the position you want to return; for example if your string was "Tom|Dick|Harry" the above would return "Dick" (2nd in array).
Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Posted: 13 Feb 2012 at 3:12am
of course if you wanted to access all the parts, you would 'split' them into an array of strings, and then you could display the parts that you want by accessing the members using the notation that rkrowland supplied...
local stringvar array pts := split({table.field}, "|");
pts[1] + " " + pts[4] // just arbitrary member values
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