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 - Show more from this author |
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 Nov 11, 2010 |
||
The function converts the list to lowercase. | ||
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 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, 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) ) ) |
||
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.