MM_FLATTENDIM function

Flattens dimensions (all or specified) of target range into one single table.

Written By Nikolas Ethoré (Super Administrator)

Updated at November 24th, 2021

Description

Flattens dimensions of target range into one single table. You can chose to return either all indexes of all dimensions or only specified indexes of loops and/or simulations.

Syntax

=MM_FLATTENDIM(Keys, WithLoopKeys, [Name, Index], [Name2, Index2], ...)
  • Keys

    Range you want to flatten.

  • WithLoopKeys (optional)

    Boolean. Value can be TRUE or FALSE. By default, set to FALSE.

    TRUE: insert one column for each dimension to identify the current dimension(s) of each line in the output table,
    FALSE: no added columns in the output table.

  • "Name", Index (optional)

    String, Integer.

    Name and dimension index of the first loop you want to return. If you want to access a specific number of simulations, use Name = "SIM".

  • "Name2", Index2 (optional)
    String, Integer.

    Name and dimension index of the second loop you want to return. If you want to access a specific number of simulations, use Name = "SIM".

  • ...

    Other loop specifications.

    Warning: The parameters Name, Name2, ... are case sensitive.

Remarks

  • This function is not meant to be used inside another function. It must be used alone in a cell.

  • If you do not mention one or several loops in the parameters, the function will return all dimensions for this/these loop(s).

  • You cannot specify the same loop with different dimensions.

  • First parameter should have dimensions. Otherwise the function will simply return the range.

  • Your input grid can have different and multiple dimensions on each column. If the second parameter is TRUE, Mind will add a key column for each dimension of the input grid.

  • You can not use Index parameter without the Name parameter.

Example 1: no specified dimension

In Mind, you can show all dimensions to a grid using the button on the top left of the grid "All available dimensions". This functionality will display values from your grid for each index of your loops existing in your grid.

Here is an extract of grid "GridLoop1" displayed with all dimensions (5 indexes for loop "Loop1"):

If you write the following formula with grid GridLoop1 which begins in cell G5:

=MM_FLATTENDIM(MM_TABLE(G5))

You will obtain grid GridLoop1 with all dimensions displayed (similar to the functionality "All available dimensions" in Mind):

You can notice here that values in both previous pictures are the same. Note that by default, the second parameter is set to FALSE if not mentioned. Thus, the output table has no additional key columns.

Example 2: Multiple loops with one specified dimension

If you have several dimensions on your input grid, you can use MM_FLATTENDIM to display dimensions of your grid corresponding to one index from a specified dimension.

Here is an extract of grid, displayed with all dimensions, with 5 indexes for the first dimension ("Loop1") and 4 indexes for dimension "Loop2":

Grid GridLoop1+2 is located in cell C19 in Excel model. If you write this formula:

=MM_FLATTENDIM(MM_TABLE($C$19), TRUE, "Loop1", 3)

The formula will return the input grid flatten with all dimensions of "Loop2" and with specified index 3 for the loop "Loop1". Thus, the FLATTENDIM grid will display 12 rows (3 rows at each index of Loop2, so 3*4):

You can notice that the 3 rows in red in previous picture are displayed as first 3 rows of this grid.

You can note here that we put TRUE to the second boolean parameter. That is why the first column of our output grid correspond to a key column which indicates the index for the loop Loop2 for each line of the grid. There is no need for a key column for Loop1 because index does not vary.