Software Venture Consulting

FileMaker Pro downloads & Resources
FileMaker Custom Functions
FileMaker Web Viewer Examples
FileMaker Pro & Lasso Consulting
Training
FileMaker Books
FileMaker Articles
FileMaker Error Reference

Free Web Tools
Free FileMaker Tools

Personal Pages
Videos
Adventures
Links

Shopping Cart
Shopping Cart

Search:

Free Newsletter
Signup


Contact


Privacy Policy



FileMaker is a registered trademark of FileMaker, Inc. in the U.S. and other countries.

 

 FileMaker Pro Custom Functions

List  |  Show Random  |  Upload  |  Add This to Your Site

AllWordCombinations (theWords)

Rate this function:  

RatingRatingRatingRatingRating
  Average rating: 4.1  (33 votes)
  Discuss this Custom Function

Michael E. Kupietz, Michael E. Kupietz, FileMaker Consultant
https://www.kupietz.com

List all possible subsets from a string of words

Sample Input:
AllWordCombinations("boy girl cat dog")
Sample Output:
boy
boy girl
boy girl cat
boy girl dog
boy girl cat dog
boy cat
boy dog
boy cat dog
girl
girl cat
girl dog
girl cat dog
cat
dog
cat dog


 Then copy & paste into FileMaker Advanced's Edit Custom Function window.

Click here to copy To Clip Manager if you have myFMbutler's Clip Manager installed

Description:

Given a string of words separated by spaces, this function returns a list of every unique combination of one or more of those words. For instance, AllWordCombinations("boy girl cat dog") will return:

"boy
boy girl
boy girl cat
boy girl dog
boy girl cat dog
boy cat
boy dog
boy cat dog
girl
girl cat
girl dog
girl cat dog
cat
dog
cat dog"

Please note: this returns all combination, not all permutations. "Boy cat" and "Cat boy" are two different permutations, but the same combination. A fruit salad made of apples and grapes is the same as a fruit salad made of grapes and apples.

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

This is my Custom Function and I want to edit it

Discuss:

5 most recent comments | Show all 8 comments

Thanks. That's what i did. (boy1, boy2) I asked in the way to understand the programmation.

In the same way, is there a way to limit the number of combinations ?
For example : For 10 elements only the combinations of 5 or less.

Thomas, Paris
December 11, 2015 10:27am

Thomas, off the top of my head, I'm sure there is. Off the top of my head, before you call the function recursively from within itself, you could just do a wordcount() on the value you're about to call it on, and if it's reached maximum length, don't make the recursive call.

Michael E. Kupietz, FileMaker Consultant, San Francisco, CA
September 29, 2016 5:46pm

Great function, has really come in handy for me. Thanks! I'm wondering if there's any way to support characters like dashes and slashes and underscores in the words. I tried changing the functions from WordCount, LeftWords, RightWords to ValueCount, LeftValues, and RightValues, but all I get is a single line of text with each of the words. I'm using this to build a record tagging feature and would like to be able to support characters like - / and $ in my tags. Thanks!

Rob, Nevada
April 09, 2017 4:37pm

Well, this is a kludge, but off the top of my head the very easiest thing to do would be to run the input string through a substitute function before passing it to the custom function, and change those characters to letter strings unlikely to be used elsewhere. For instance:

substitute(string, ["-","XYZABCDASHXYZABC"],["/","XYZABCSLA SHXYZABC"],["$","XYZABCDOLLARXYZABC"])

so they become embedded as text into the surrounding words ("tag1-subtag1" becomes "tag1XYZABCDASHXYZABCsubtag1") and treated as single words by the function. Then just do the reverse substitution on the output of the function to replace those strings with the original punctuation.

Glad you're finding it useful, thanks!

Michael E. Kupietz, FileMaker Consultant, San Francisco, CA
April 09, 2017 9:26pm

Oops, there shouldn't have been a space in "XYZABCSLASHXYZABC", above.

Michael E. Kupietz, FileMaker Consultant, San Francisco, CA
April 09, 2017 10:21pm

Make a comment about this Custom Function (please try to keep it brief & to the point). Anyone can post:

Your Name:
City/Location:
Comment:
characters left. If you paste in more than 1500 characters, it will be truncated. Discuss the function - advertisements and other useless posts will be deleted.
Answer 5 + 5 =
Search for Custom Functions:

Custom Functions Widget
Download the Custom Function Dashboard Widget for OS X
Keep all the latest Custom Functions right at your fingertips!

Newest Custom Functions:

1. decFromHex ( hexValue )
  (Mon, Oct 16, 12:34pm)
2. MonthYearList ( startmonth ; startyear ; numbermonth ; short )
  (Mon, Oct 16, 3:38am)
3. ErrorDescription ( errorNumber )
  (Wed, Sep 27, 2:51am)
4. decodeEntities (text)
  (Wed, Sep 27, 1:22am)
5. HexidecimalToNumber ( HexidecimalValue ; counter )
  (Mon, Sep 25, 12:39pm)
6. FixedFieldConverter ( Fieldname ; f1 ; f2 ; f3 ; f4 ; f5 ; f6 ; f7 ; f8 ; f9 ; f10 ; f11 ; f12 ; f13 ; f14 ; f15 ; f16 ; f17 ; f18 ; f1
  (Fri, Sep 15, 12:34pm)
7. ShannonEntropy ( text )
  (Thu, Sep 07, 5:59am)
8. LetterCount ( text ; summary )
  (Thu, Sep 07, 5:53am)

RSS Feed of Custom Functions