5 Replies Latest reply on Jan 22, 2014 4:22 PM by hsiaomayi

# How to calculate product (multiply a set of numbers)?

### Title

How to calculate product (multiply a set of numbers)?

### Post

I need to out put the PRODUCT of a set of number, but it seems this is not a standard function/calculation in FM.  Any one can help me to achieve the calculation?

• ###### 1. Re: How to calculate product (multiply a set of numbers)?

Is each number in a different field of the same record?

Is each number in the same field, but in different records?

In different repetitions of a repeating field?

All in a text field separated by some delimiting character such as a return?

• ###### 2. Re: How to calculate product (multiply a set of numbers)?

The numbers are in multiple records in a different table which related to the overview table, all are in the same field (no repetition) in that table.

I like to calculate the average and the PRODUCT of those numbers

• ###### 3. Re: How to calculate product (multiply a set of numbers)?

Average (mean) can be calculated either with a summary field or the Average() aggregate function.

Depending on your data model, either List or ExecuteSQL could be used with the Evaluate function to compute the product of your data.

If you have this relationship:

Parent----<Data

where you want the product of a value in a field in Data for all records related to a given record in Parent,

This calculation:

Evaluate ( Substitute ( List ( Date::FactorField ) ; ¶ ; " * " ) )

will compute the product

In other situations where a simple relationship won't work, an SQL query inside ExecuteSQL() might be used:

Evaluate ( ExecuteSQL ( "SQL query goes here" ; "" ; " * " ) )

• ###### 4. Re: How to calculate product (multiply a set of numbers)?

PhilModJunk

That is exactly the relationship.

Many thanks

• ###### 5. Re: How to calculate product (multiply a set of numbers)?

PS, it worked beautifully.  Thanks!