# Modify values from grouped rows

Use the Modify values from grouped rows step to build complex hierarchical data and group data based on a hierarchical data field by using path definitions on an ordered group of input rows.

This step modifies hierarchical data to form nested JSON key-value pairs. It can also build complex data by nesting arrays, objects, and key-value pairs. The step takes non-hierarchical data and converts it to hierarchical data and sends it to other steps.

For more information, see [Hierarchical data](https://docs.pentaho.com/pdia-data-integration/extracting-data-into-pdi/hierarchical-data).

### Step name

* **Step name**: Specify the unique name of the Modify values from grouped rows step on the canvas. You can customize the name or leave it as the default.

### Grouping fields

![Modify values from grouped rows step window](https://773338310-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYwnJ6Fexn4LZwKRHghPK%2Fuploads%2Fgit-blob-c940acd737e5c35ba94faf9381bb0f30271156f7%2FPDI%20Modify%20values%20from%20group%20rows%20step%20window.png?alt=media)

| Field             | Description                                                      |
| ----------------- | ---------------------------------------------------------------- |
| **Field name**    | Specify the field name to group the incoming data.               |
| **Pass through?** | Select to add the specified incoming field to the output fields. |

In **Target hierarchical**, specify a new field name to add to the output, or select an incoming hierarchical field name to modify.

{% hint style="info" %}
If the target field is an existing field, it must be included as one of the grouping fields.
{% endhint %}

### Modifications

* **Hierarchical path**: Specify the path to modify or create inside the target hierarchical field. See [Hierarchical data path specifications](https://docs.pentaho.com/pdia-data-integration/pdi-transformation-steps-reference-overview/broken-reference).
* **Action**: The action to perform on the target field.
  * **SET**: Set the target hierarchical path to the value specified in **Value field name**.
  * **SET\_IGNORE\_NULL\_VALUE**: Perform **SET** only if the value field is not null.
  * **SET\_IF\_NULL**: Set the target hierarchical path to the value specified in **Value field name** if the target path is null.
  * **UNSET**: Unset the target hierarchical path.
    * Example: `before: { hello: null, hello2: 10 }, after: {}`
  * **UNSET\_IF\_NULL**: Unset the target hierarchical path if the value stored at the path is null.
    * Example: `before: { hello: null, hello2: 10 }, after: { hello2: 10 }`
* **Value field name**: Specify the field to use for the action.

### Example

The sample transformation `Modify_From_Grouped_Rows.ktr` demonstrates the capabilities of this step and is available in the plugin distribution package in the `data-integration/plugins/hierarchical-datatype-plugin/samples/transformations` directory.

This step is also demonstrated in `Advanced_Using_Multiples_To Join_And_Edit.ktr`. Comments in the transformation explain how the steps are used.

![Modify values from grouped rows example KTR](https://773338310-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYwnJ6Fexn4LZwKRHghPK%2Fuploads%2Fgit-blob-7185652443ca1b6a2d6330d0a20b5eaebd6bd435%2FPDI%20Modify%20values%20from%20group%20rows%20example%20ktr.png?alt=media)
