MM_COUNTIF function

Returns the number of dimension indexes of a range that meet a chosen criterion.

Written By Nikolas Ethoré (Super Administrator)

Updated at November 24th, 2021

Description

The equivalent of COUNTIF Excel function. Returns the number of dimension indexes of a range that meet a chosen criterion. It is possible to specify the index of one or several loops for which you want to apply the function. 

Syntax

=MM_COUNTIF(Value, Condition, ["Name", Index], ["Name2", Index2], ...)
  • Value
    Cells to be counted if they meet the given criterion.

  • Condition
    The criterion used to select which values to be added to the total count. 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. 

  • "Name", Index (optional)
    String, Integer.
    Name of a loop and index of that same loop you want to access to count 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 count the results of one specific simulation, you can specify "SIM" as Name and the desired simulation index under Index.

 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_COUNTIF, if Value has no multiple dimensions. In that case, it is more consistent to use COUNTIF Excel function.

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

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

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

Example 1: No loop and simulations

Formula1: =MM_COUNTIF(A2,">0.5"). Given the number of simulations in Mind, the formula returns the number of simulations (out of n) 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 2.

Example 2: Two loops, no specified dimension

In this example, the cell A7 depends on Loop1 and Loop2; it has 4 dimensions.
The formula :=MM_COUNTIF(A7,">40") returns 2, it is the number of dimensions of A7 whose result is greater than 40. Indeed, the four values of A7 are 37, 38, 47 and 48; two values are greater than 40.

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.
The formula :=MM_COUNTIF(A7,">40","Loop1", 1) returns 0, it is the number of dimensions of cell A7 whose result is greater than 40 taking into account only the first dimension of Loop1. The values of A7, with dimension of Loop1 equal to 1, are 37 and 38.

Example 4: Loops and simulations

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