MM_BATCHINDEX function

Returns the index of the selected BATCH in Mind settings. Used to run a chosen number of scenarios from your BATCH loop.

Written By Nikolas Ethoré (Super Administrator)

Updated at November 24th, 2021


Description

Returns the index of the selected BATCH in Mind settings. MM_BATCHINDEX function is used in conjunction with the header /batchresult to create a loop named BATCH for the tables labeled with /batchresult. The difference with MM_LOOP is that you can choose which scenarios to run (instead of all) and for which tables you want to save all dimensions of the BATCH loop. It is mostly used if your scenarios requires long calculation time and you wish to only run a few of them. 

Syntax

=MM_BATCHINDEX()

No parameters. 

Remarks

To learn how to access BATCH settings, see Run batches (split stochastic runs to save RAM)‍. The BATCH settings should look like this:

  • The first parameter, "Nbr of batches", is the size of your BATCH loop, in other words, the maximum number of scenarios for this loop. 

  • The second parameter, "selected batch", is the index of the BATCH scenario you want to run. You can select one scenario or all scenarios. In that case, it will create a BATCH loop and run all scenarios from 1 to "Nbr. of batches". 

Example 1: One scenario

Case 1:
In the above example with (Nbr of batches, Selected batch) = (4,1), the formula =MM_BATCHINDEX() returns 1.

Case 1bis: 
With (Nbr of batches, Selected batch) = (4,3), the formula =MM_BATCHINDEX() returns 3.

Example 2: All scenarios

When "All" is selected for the second parameter, Mind creates a BATCH loop for tables labeled with /batchresult

Case 2:
With (Nbr of batches, Selected batch) = (4,All), the formula =MM_BATCHINDEX() returns 1 for dimension 1, 2 for dimension 2, 3 for dimension 3 and 4 for dimension 4 of the BATCH loop.

Note that this is only visible in Mind for tables labeled with /batchresult. You will not be able to naviguate through the BATCH dimensions for tables without the /batchresult header. In that case, the results will be the ones from the first dimension by default, that is to say with the BATCH index equal to 1. 

Case 2bis:
With (Nbr of batches, Selected batch) = (2, All), the formula =MM_BATCHINDEX() returns 1 for dimension 1 and 2 for dimension 2 of the BATCH loop. 

Example 3: Design your model with MM_BATCHINDEX

Note that MM_LOOP always run all scenarios et save all dimension results in the entire model. Besides, it uses a range as parameter whereas MM_BATCHINDEX has no parameter.

To use MM_BATCHINDEX in your model, you have to use OFFSET or INDEX Excel functions as shown above.

The picture above shows the results of the Excel file imported in Mind. Notice that the result in C2 and in C6 are the same. However, by using MM_BATCHINDEX, an intermediate step is required. Indeed, MM_LOOP directly calls the range it loops on whereas MM_BATCHINDEX has no parameter. 

Now, let us say you want to run the second and third scenarios ("Scenario B" and "Scenario C") instead of the first two scenarios. To this end, you must add another intermediate step. The first index of BATCH must refer to "Scenario B" and the second index of BATCH to "Scenario C", using an OFFSET Excel function.