New List Based On Portion Of List

Here is a fairly useful method of using formula language to pick out values
from a list of multiple values based on matching a "portion" of each element
without using a view.

Say you original list "List1" contains the following:

List1 := "Apples|Fruit|$1.25" : "Oranges|Fruit|$1.10" : "Peas|Vegatable|$0.55"
: "Bannanas|Fruit|$1.50" : "Tomatos|Debatable|$0.95"

You want to create a new list of only those elements that are fruit.
List1 := "Apples|Fruit|$1.25" : "Oranges|Fruit|$1.10" : "Peas|Vegatable|$0.55"
: "Bannanas|Fruit|$1.50" : "Tomatos|Debatable|$0.95"

List2 := @Word(List1;"|";2);
List3 := @Replace(List2; "Fruit"; "");
List4 := List1 + List3;
List5 := @Replace( List1; List4; "");
List6 := @Trim(@Replace(List1; List5; ""));

Now "List6" contains the final list and can be used like this:

@Word(List6;"|";1) + " - " + @Word(List6;"|";3)

giving you a fruit list like this -

Apples - $1.25
Oranges - $1.10
Bannana - $1.50

Optional Description of each step:
List1 - Original List
List2 - List of the second "words" in each element (Fruit, Fruit, Vagetable,
Fruit, Debatable)
List3 - List of seconnd words in element with one we want to keep Null
List4 - Original List with "word 2" appended to change the elements we don't
List5 - Replaces the words that didn't change with Null to make a mask of what
to remove
List6 - (Final List) Use the mask to Null what we don't want and trim results
to remove Nulls from list.

This was first published in November 2000

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.