**Given**:

https://www.filemaker.com/help/15/fmp/en/index.html#page/FMP_Help/aggregate-functions.html

Aggregate functionsNote Aggregate functions perform statistical analysis on numbers (and dates or times for some functions) in:

- several fields in a record.
- related fields whether displayed in a portal or not.
- repeating fields

.

**Desired**:

change the "field(s)" to "field(s) or variable(s)"

**Why**?

There are many times that the built-in aggregate functions do the job, but only when the data is in a field. This idea may be prohibitive, but if so, please reply with a why!

List() is considered an 'aggregate' and allows variables:

https://www.filemaker.com/help/15/fmp/en/index.html#page/FMP_Help/list.html

field- any related field, repeating field, or set of non-repeating fields; an expression that returns a field, repeating field, or set of non-repeating fields, or avariable.

So? allow the other aggregates use variables!

**Example**:

Let (

[ _mylist = List ( 1 ; 2 ; 3 ; 4 )

; _return = Average ( _mylist )

]; _return

) //

ERROR: <Field Missing>

**Why not**?

Yes, there are custom functions. Yes, there are ways to use external (i.e. Javascript). Yes, there are plug-ins.

Just posting an idea.

beverly

I don't think the issue is Aggregates and variables. Aggregate functions do permit variables. The error message for Aggregates often claims a need for a field, but that's misleading. Regular numbers work just fine. As do variables that resolve to numbers. Aggregates do not like to be fed a single parameter that is not a field.

For example this works fine:

Let ( [

$x = 5 ;

$y = 4 ];

Average ( $x ; $y )

) //4.5

Even this works fine...

Let (

$x = 4 ;

average ( $x ; $y )

) //4

But you run into problems with passing a single, non-field parameter such as:

Average ( 5 ) //ERROR

and

Let(

$x = "4¶5" ;

average ( $x )

) //ERROR

That last one is what I think you’re suggestion is trying to address. I'm sympathetic, it would be nice to feed a value delimited list to an Aggregate and get a result.

Evaluate() is really handy here. You can do all sorts of things with the Aggregate functions, a list of values, and Evaluate().

For example:

Let (

[ _mylist = List ( 1 ; 2 ; 3 ; 4 )

; _function = "Average ( " & Substitute ( _mylist ; "¶" ; " ; " ) & " ) "

//Average ( 1 ; 2 ; 3 ; 4 )

;_return = Evaluate ( _function )

]; _return

) //2.5

Also if $$my.list = 1¶2¶3¶4

Let (

[ _function = "Average ( " & Substitute ( $$mylist ; "¶" ; " ; " ) & " ) "

//Average ( 1 ; 2 ; 3 ; 4 )

;_return = Evaluate ( _function )

]; _return

) //2.5