MM_AVERAGEIF function

Returns the average of values of all dimensions or specified dimensions of a range that meet a chosen criterion.

Written By Nikolas Ethoré (Super Administrator)

Updated at November 24th, 2021

Description

Equivalent of AVERAGEIF Excel function. Returns the average of values of all dimensions or specified dimensions of a range that meet a chosen criterion. 

Syntax

=MM_AVERAGEIF(Value, Condition, [Average_value], ["Name", Index], ["Name2", Index2], ...)
  • Value
    Cells to be averaged if they meet the given criterion. If the Average_value parameter is input, only the position of the cells and the index of the dimensions of Value are used; the corresponding values of Average_value are averaged. 

  • Condition
    The criterion used to select which values to be averaged. Can be string, number or cell reference. Criterion that includes logical symbols (=, >, <) must be written as a string. Ex: ">0".
    Warning: If your version of Excel does not use English notation, be sure to use a decimal point for string criteria. For instance, write ">12.5" instead of ">12,5" as the cultural translation is not automatic for strings. 

  • Average_value (optional)
    The actual range to average. If this parameter is not specified, Value is used by default. 

  • "Name", Index (optional)
    String, Integer.
    Name of a loop and index of that same loop you want to access to average values. If you do not specify any index for a loop, Mind takes all indexes for that loop.
    For stochastic dimension: if you want to average the results of one specific simulation, you can specify "SIM" as Name and the desired simulation index under Index.

Delete

 Warning: The parameter LoopName is case sensitive.

  • "Name2", Index2, "Name3", Index3, ...etc. (optional)
    String, Integer.
    Names and indexes of other loops. 

Remarks

  • There is no point in using MM_AVERAGEIF, if Value (or Average_value) has no loop or stochastic dimensions; the function automatically returns Value without applying the criterion. In that case, you must use AVERAGEIF Excel function.

  • You cannot specify the same loop with different indexes. If you want to average two different dimensions of the same loop, one possibility is to use twice the MM_RESULT function for each dimension and an AVERAGEIF Excel function. 

  • Remember to input Average_value if you input Name, Index, Name2, Index 2, ..., even if Average_value is equal to Value as Mind does not accept empty parameters.

  • For MM_AVERAGEIF to work correctly, Value and Average_value must have the same range size and loop dimensions. If you use a range and not a single cell in your parameters, the cells of your range also need to have the same dimensions.

  • If no dimension value of the cells of Value meet the criterion Condition, the function returns the error NaN.

  • See MM_AVERAGEIFS function‍ to add a set of criteria.

Example 1: No loop and simulations

Formula1: =MM_AVERAGEIF(A2,">0.5"). Given the number of simulations in Mind, the formula returns the average of the n simulations whose result is greater than 0.5. If n=3 and the results in A2 are 0.4, 0.56, 0.89, then A3 returns 0.725.

Example 2: Two loops, no specified dimension

In this example, the cell A7 depends on Loop1 and Loop2; it has 2 dimensions of size 2, which amount to 4 values.
The formula :=MM_AVERAGEIF(A7,">20") returns 42.50, it is the average of cell A7 for the values whose result is greater than 20. Indeed, the four values of A7 are 37, 38, 47 and 48; they are all greater than 20. The average of these four values is 42.50.

Example 3: Two loops, specified dimension

This example is similar to the one above but we choose to specify the index of the first loop. We set it to 1. Note that, in this case, the third parameter must be input.
The formula :=MM_AVERAGEIF(A7,">20", A7,"Loop1",1) returns 37.50, it is the average of cell A7 for the values whose result is greater than 20 taking into account only the first index of Loop1. The values that are averaged are 37 and 38.

Example 4: Loops and simulations

It is possible to mix the first example and the second example to average cells with loop and stochastic dimensions.