Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 6084 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

How do I extract the first occurrence of any item in a list from a field?

Field A contains lengthy text. Within that text is the description of a fabric. The predominate fabric always appears ahead of the lesser fabric i.e., “...75% polyester, 25% cotton...”

I want Field B to show the first occurrence of any of the values in the following list. “Polyester” in the above example.

Any help would be appreciated.

...full grain cowhide

full grain pigskin

full-grain cowhide

full-grain pigskin

suede cowhide

polypropylene

Work-Dry® mesh

PVC

CoolMax® polyester

wool

polyester

polyester fleece

Merino wool

cotton rigid denim

cotton denim

cotton canvas

cotton drill...

Posted

Something like this, I suppose:

Let ( [

pos = Position ( listOfValues ; searchString ; 1 ; 1 ) ;

start = Position ( ¶ & listOfValues ; ¶ ; pos ; -1 ) ;

end = Position ( listOfValues & ¶ ; ¶ ; pos ; 1 )

] ;

Middle ( listOfValues ; start ; end - start )

)

Posted

Perhaps I don't understand your question. The value of searchString would be "“Polyester” in your example, and given the same list of values, it would find the "polyester" value in the list. Now that I read it, I see it could be interpreted the other way round, that is you want to find values from the list in the text.

Posted

Yes, it would be best to use a custom function here. Would you know how to adapt this one (actually it's two)? Or perhaps just the highlighting itself might suit your needs:

http://www.briandunning.com/cf/579

Posted

I will take a look and give it a try. I don't have much experience with CFs, but now is as good a time as any to start.

Thanks for steering me in the right direction.

Posted

On second thought, this is not so simple at all. Consider a description like:

“...75% polyester fleece, 25% polyester...”

If you search for "polyester" in this description, it's going to have the same position as "polyester fleece", because "polyester" is contained in "polyester fleece". So it's more or less a flip of the coin whether you get "polyester" or "polyester fleece" as the result, unless...

You either look for the longest value among the values that scored equal, or you extract the materials from the description and look for them in the list of materials - somewhat similar to my first suggestion.

I have implemented the former in the attached file, using two repeating fields instead of a custom function. Perhaps if we knew the actual purpose here, a simpler way to solve the real problem behind this could be found.

FirstValueR.fp7.zip

Posted (edited)

Hello,

can be I will seek to extract starting from the first list.

I try this calculation

Let ( [



Fabric = "75% Polyester, 45% Cotton" ; /* carefull to the double spaces and other - control of seizure */

ListOfValues = YourListOfValues ;



Values = Substitute ( Fabric ; ["% " ; ¶] ; ["%" ; ¶] ; ["," ; ¶] ) ; // cleaning datas

Value = GetValue ( FilterValues ( Values ; ListOfValues ) ; 1 ) ; // Find First Value - respect the order of lists



Pos = Position ( ¶ &  ListOfValues & ¶ ; ¶ & Value  & ¶ ; 1 ; 1 ) ; // Position Value in listOfValues

Color = Replace ( ListOfValues ; Pos ; Length ( Value ) ; TextColor ( Value ; RGB ( 250 ; 0 ; 0 ) ) ) ; // Color Value in your list....

NbrValuePos = ValueCount ( Left ( ListOfValues ; Pos ) ) // number in list



] ;

Value & " is " & NbrValuePos & " value in the list" & "¶ -  -  -  -  - ¶" & Color

)

but I added variables because I think I do not understood everything...

perhaps B)

Agnès

Edited by Guest
Olé !!! much color in the code!!
Posted

Field A contains lengthy text. Within that text is the description of a fabric.

I think we need more rules here. It's easy to break both suggested methods if the text and/or the fabric description do not adhere to SOME consistent pattern.

For example, my method will falsely identify any fabric that appears in the "lengthy text" BEFORE the description as the first occurrence, and Agnès' method will break if the description items are not separated by commas.

At minimum, we should be able to identify where in the text the description begins. Otherwise this is an attempt to arm Filemaker with artificial intelligence, and it's doomed to fail.

This topic is 6084 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.