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!

displaying only certain part of a string 1

Status
Not open for further replies.

adnil

Technical User
Oct 29, 2003
50
GB
Hi

We have the following string:

Learning Objective - To consolidate knowledge and understanding of electricity generation.
Activity - Generation of electricity. Resources provided by company. Read, discuss then employee to complete set tasks.
Evaluation - Objective achieved

What we need is for the above info to be displayed in crystal XI in 3 different columns with Learning Objective, Activity and Evaluation as the respective column heading.

I have created 3 different formulas using split function:
@learning objective - split({MEMO_STR.MEMO_DATA},'Learning Objective - ')[2]
@activity - split({MEMO_STR.MEMO_DATA},'Activity - ')[2]
@evaluation - split({MEMO_STR.MEMO_DATA},'Evaluation - ')[2]

@evaluation works fine, the result of the formula is showing Objective achieved. However @learning objective is showing To consolidate knowledge and the rest of the string and @activity is showing Generation of electricity and the rest of the string.

How can I get @learning objective and @activity to show only the relevant text please?

Thank you.

Lin
 
Assuming the data is exactly as posted above, ie, each of the 3 components are separated by a Carriage Return / Line Feed character, you could first split on that character. For example, the Learning Objective formula would look like this:

[Code {@Learning_Objective}]
Split(Split({@EMO_STR.MEMO_DATA}, CHR(13))[1], "Learning Objective - ")[2]
[/Code]

I have used CHR(13) but it could be CHR(10) or possibly CHR(11).

If the data is not consistently formatted with a Carriage Return / Line Feed, try the following:

[Code {@Learning_Objective}]
Split(Split({MEMO_STR.MEMO_DATA}, "Learning Objective - ")[2], "Activity - ")[1]
[/Code]

Either way, success or otherwise will be reliant on the consistency of the data.

Hope this helps.

Cheers
Pete
 
Hi Pete

Thank you for much for your suggestions. The 3 components are separated by carriage return. When I try your first suggestion, it did not work. However, your 2nd suggestion work perfectly.

Thank you.

Lin

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top