I also could not find an obvious answer - it does not help that the term is Mode and mode is used by FMP for it's display types.
Brian Dunnings Custom Functions did not seem to have one
This FMP article is not about Mode but Unique Values
There may be an ExecuteSQL that would provide a Mode
Counting the Number of Unique Values in a Field
How do I count the number of unique values in a field?
Hmmm, If Brian's site doesn't have one, Maybe I should upload this one to that site:
// Mode ( ValueList ; Value; Cnt )
// valueList : A return separated list of values. values can be text or number
// value : Iterim value that passes the current mode candidate to the next recursive call of the function.
// Cnt : The count of the items of the currently nominated value
Let ( c = ValueCount ( FilterValues ( ValueList ; GetValue ( valueLIst ; 1 ) ) ) ;
Case ( IsEmpty ( ValueList ) ; Value ; // return current data in Value if list is empty
c > Cnt ; Mode ( RightValues ( ValueList ; ValueCount ( ValueList ) - 1 ) ; GetValue ( ValueList ; 1 ) ; c ) ;
Mode ( RightValues ( ValueList ; ValueCount ( ValueList ) - 1 ) ; Value ; Cnt )
) // case
) // let
Brilliant - this is exactly what I was looking for! Quite surprising that this wasn't already on the list of custom functions. Thanks very much for the insightful replies and for posting the custom function.
When there is a tie between two values that occur equally commonly, either value may be returned, do I understand that correctly?
It's been ages since I created that one in response to another post here in the forum. If I am mentally analyzing the code correctly, in cases of a "tie" the "leftmost" value (the first to be counted) is returned. A new value is selected and stored in the function parameter only if its count is greater than the currently selected value's count so a "tie" doesn't change the value passed in that parameter.
And I did go ahead and upload this one to the Brian Dunning site after confirming for myself that there isn't already such a function in place.
Thanks again for your help, and for posting to Brian Dunning's site. It's a very useful function.