Description
Returns the index of the selected instance in a table.
Syntax
=MM_INSTINDEX()No parameters.
Remark
See MM_DIMINDEX function the equivalent function for loops.
Example 1: Basic example
Instances have to be added beforehand. To learn more about instances, check Introduction to instances.
Do not forget to run the model after adding instances.
In this example, we have two instances: "Instance #1" and "Instance #2".

Below, Instance #1 is selected (to do so, you need to click on the instance name at the top of the table). The function MM_INSTINDEX() returns 1 because Instance #1 corresponds to the first instance.

Below, Instance #2 is selected. The function MM_INSTINDEX() returns 2 because Instance #2 corresponds to the second instance.

Example 2: Loops specific to instances
Using MM_INSTINDEX, you can create loops specific to instances, that is to say with different names for each instance.

Formula: =MM_LOOP("Loop " & MM_INSTINDEX(),MM_COLUMN(A2))
This function creates as many loops as there are existing instances. "Loop 1" is specific to the first instance, "Loop 2" to the second instance, and so on. Thus, "Loop 1" will not appear when you select an instance other than Instance #1.
Another possibility: LoopNameCol is a column range that contains all loop names. The INDEX function will pick the desired name for the current chosen instance.

N.B: The loops do not need to have the same size. As showed in the example, the dimensions for the loop correspond to the whole column of the table #Data, which can be dynamic.