# Hierarchical output structure editor

The flat to hierarchical map feature allows you to define a hierarchical output structure.

The examples in the following table use the CSV sample provided in [Creating a hierarchical map from a flat structure](https://help.qlik.com/talend/en-US/data-mapper-user-guide/8.0/creating-hierarchical-map-from-flat-structure) as input.

| Feature | Description | Example |
| --- | --- | --- |
| Add GroupBy | Arranges the children elements into a set of groups based on the value of the<br>selected GroupBy element.<br><br>If a single element is selected, an array with all unique values for this element is<br>created.<br><br>If multiple elements are selected, the first child element in the selection is<br>automatically used as the GroupBy element. You can change it by<br>right-clicking a child element and clicking Select as GroupBy<br>element. | <ul> <li>If you select the <span>Gender</span> element and click <span>Add                    GroupBy</span>, the output looks like this:<pre><code><pre><code><code>"Gender": [  "female",  "male"]</code></code></pre></code></pre> </li> <li>If you select the <span>Gender</span> and <span>Name</span> elements,                  the output looks like this:<pre><code><pre><code><code>"Oscars": [  {    "Gender": "female",    "Name": "Jessica Tandy"  },  {    "Gender": "male",    "Name": "Daniel Day-Lewis"  }]</code></code></pre></code></pre> </li> </ul> |
| Add Array | Creates a collection of elements that loops on the input row element<br>if it exists, and the input root element otherwise.<br><br>If a single element is selected, a primitive array containing the value of the<br>element is created. If multiple elements are selected, an array of records is<br>created.<br><br>When this feature is used on an element inside a GroupBy, it<br>allows you to create groups. | <ul> <li>If you select the <span>Movie</span> element and click <span>Add                    Array</span>, the array looks like this:<pre><code><pre><code><code>"Movie": [  "Driving Miss Daisy",  "Misery",  "The Silence of the Lambs"]</code></code></pre></code></pre> </li> <li>If you select the <span>Movie</span> and <span>Name</span> elements, the                  array looks like this: <pre><code><pre><code><code>"Movies": [  {    "Name": "Jessica Tandy",    "Movie": "Driving Miss Daisy"  },  {    "Name": "Kathy Bates",    "Movie": "Misery"  }]</code></code></pre></code></pre> </li> </ul> |
| Add Record | Creates a record from the elements selected. | If you select the Movie and Year elements, the<br>record looks like this:<br><br>```<br>"Movie_record": {<br>"Year": "1990",<br>"Movie": " Driving Miss Daisy"<br>}<br>``` |
| Convert GroupBy/Array Item Type | Changes an array or a set of groups from a primitive item type to a record item type,<br>or the other way around.<br><br>Information noteNote: This option is available on a record item only when the<br>records contains a single element. | If you create an array from the Movie element and click<br>Convert GroupBy/Array Item Type, the array looks like<br>this:<br><br>```<br>"Movie_array": [<br>{<br>"Movie": "Driving Miss Daisy"<br>},<br>{<br>"Movie": "Misery"<br>},<br>{<br>"Movie": "The Silence of the Lambs"<br>}<br>]<br>``` |
| Convert to Array | Converts a set of groups into an array. | If you convert groups containing the Gender and<br>Name elements grouped by Gender into an array, the<br>array looks like this:<br><br>```<br>"Gender_array": [<br>{<br>"Gender": "female",<br>"Name": " Jessica Tandy"<br>},<br>{<br>"Gender": "female",<br>"Name": " Kathy Bates"<br>},<br>{<br>"Gender": "male",<br>"Name": " Daniel Day-Lewis"<br>},<br>{<br>"Gender": "male",<br>"Name": " Jeremy Irons"<br>}<br>]<br>``` |
| Convert to GroupBy | Converts an array into groups.<br><br>By default, the first child element in the array is automatically selected as the<br>GroupBy element. You can change it by right-clicking a child<br>element and clicking Select as GroupBy element.<br><br>You can also convert the root element into a set of groups. | If you convert the root element to a group and select<br>Year as the GroupBy element, the output<br>looks like this:<br><br>```<br>[{<br>"row": [<br>{<br>"Index": "1",<br>"Gender": "female",<br>"Year": "1990",<br>"Age": "80",<br>"Name": " Jessica Tandy",<br>"Movie": " Driving Miss Daisy"<br>},<br>{<br>"Index": "28",<br>"Gender": "male",<br>"Year": "1990",<br>"Age": "32",<br>"Name": " Daniel Day-Lewis",<br>"Movie": " My Left Foot"<br>}<br>]<br>}]<br>``` |

Information noteTip: You can move elements using drag and drop, and you can duplicate elements in the output structure by copying and pasting them. When adding or duplicating elements, make sure the element names are unique to avoid errors.