MM_LOOPINSTANCE function

Create a named loop on defined range per instance.

Written By Son Nguyen (Administrator)

Updated at September 13th, 2023

Description

This function creates a named loop on defined range per instance. Range should have only one column or only one row.

Syntax

=MM_LOOPINSTANCE(Name, MaxSizeRange, InstanceSizeRange, Index(Optional), IndexStart(Optional))
  • Name: Loop name

  • MaxSizeRange: Target maximum range that defines size of loop.

  • InstanceSizeRange: Target range that changes per instance.

  • Index (Optional): Range index to be displayed in Excel (default =1).

  • IndexStart (Optional): Index of first element to be looped (default =1).

 Warning: The parameter LoopName is case sensitive.

Remarks

  • If the size of your target range is lower than the target maximum range, Mind considers the rest of elements in the loop as empty cells.

  • If the size of your target range is greater than the target maximum range, the loop ends at the target range index of your target maximum range value.

  • Specific case of one cell as the target range: elements from the loop begin at 1 to end at the minimum between target maximum range value and the value of your target cell.

Example 1: Basic example

Let us consider the following table with the formula in cell H5:

In this case, the target maximum range of your loop is 5 (written in cell J3), and the target range is the column which starts in E4 and ends at E8 (last element of the column) for instance Product A.

Considering the following inputs imported to this table with instances split (more details on how to split data according to instances in this article):

We can find that the formula will return at each instance (Product A , Product B, Product C) the same loop with respectively an empty cell at first index, 2 at the second index, empty cells at the third and fourth index, and finally 2 at the fifth and last index.

If the range imported in the column Value2-formula at the instance Product A is (5,3,2,1,0), the formula will return a loop including elements of the same range at the instance Product A, and a loop including the same elements as seen before at the two other instances.

Example 2: One cell as target range

Let we consider the following table with a MM_LOOPINSTANCE formula:

The target value is here the first value of each different instance key. The maximum range is fixed at 5 here (cell E9).

Considering the following inputs imported to this table with instances split:

The formula will return here a loop with elements from 1 to 5 for the instance Product A (5 is the first value of the key Product A), a loop with values from 1 to 3 for instance Product B (and empty values at index 4 and index 5 of this loop), and finally a loop with just one value equals to 1 for the instance Product C (and empty cells until index 5 of this loop).

If first value of the key Product A is 6, the matching loop will stop at the value 5, because the size of loop is here 5 (it is the target maximum range).