Brian Dunning's FileMaker Custom Functions

SummariseValues ( values ; separator )

Summarises the values in a paragraph delimited list. The format of the output is value & separator & count¶ with a paragraph after the last value.

  Average rating: 4.4 (39 votes) Log in to vote

Vaughan Bromfield   Vaughan Bromfield - Show more from this author

Share on Facebook Share on Twitter

  Sample input:
SummariseValues ( "a¶b¶c¶a¶c" ; "=" )
  Sample output:
a=2¶b=1¶c=2¶

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

SummariseValues( values ; separator )
by Vaughan Bromfield

Summarises the values in a paragraph delimited list. The format of the output is: value & separator & count¶ with a paragraph after the last value.

Uses the Trim4() custom function.


Let(
[
allvalues = Trim4( Lower( values ) ) ;
firstvalue = Trim4( GetValue( allvalues ; 1 ) ) ;
firstcount = PatternCount( "¶" & Substitute( allvalues ; "¶" ; "¶¶" ) & "¶" ; "¶" & firstvalue & "¶" ) ;
newvalues = Trim4( Substitute( "¶" & Substitute( allvalues ; "¶" ; "¶¶" ) & "¶" ; [ "¶" & firstvalue & "¶" ; "" ] ; [ "¶¶" ; "¶" ] ) )
] ;

Case(

IsEmpty( allvalues ) ; "" ;

firstvalue & separator & firstcount & "¶" & SummariseValues( newvalues ; separator )

)

)

 

Comments

Vaughan Bromfield   Vaughan Bromfield
Nov 11, 2010
The function converts the list to lowercase.
 
Abraham Entezari   Abraham Entezari, Earth
Apr 19, 2016
Hello there,
My name is Abraham. I just downloaded the above named custom function but the manage custom function in filemaker does not accept it with popup saying “too many parameter”. Do you have any idea?
Thank you very much
Abraham
 
Vaughan Bromfield   Vaughan Bromfield
Apr 19, 2016
Hello Abraham

When defining the custom function in your database, do it in this order:

1) Enter the function name "SummariseValues"

2) Add the "values" and "separator" parameters (type each name and click on the little green + symbol)

3) Paste the calculation expression into the body of the custom function.

If it's done in this order then it should work.

My guess is the add parameters step has been missed.

All the best,


Vaughan
 
Richard Dyce   Richard Dyce, Dyce & Sons Ltd.
Aug 16, 2017
A minor alteration, possibly of use: instead of a separator, a string format template is supplied, with n being replaced with the summary count. It makes appending things like " (n)" easier, but still allows for "separator n" type formatting...

// SummariseValues ( values ; suffixFormat )
Let(
[
allvalues = Trim4( Lower( values ) ) ;
firstvalue = Trim4( GetValue( allvalues ; 1 ) ) ;
firstcount = PatternCount( "¶" & Substitute( allvalues ; "¶" ; "¶¶" ) & "¶" ; "¶" & firstvalue & "¶" ) ;
newvalues = Trim4( Substitute( "¶" & Substitute( allvalues ; "¶" ; "¶¶" ) & "¶" ; [ "¶" & firstvalue & "¶" ; "" ] ; [ "¶¶" ; "¶" ] ) )
] ;

Case(
IsEmpty( allvalues ) ; "" ;
firstvalue & Substitute( suffixFormat ; "n" ; firstcount ) & "¶" & SummariseValues( newvalues ; suffixFormat)
)
)
 

Log in to post comments.

 

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

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 15 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: