> ## Documentation Index
> Fetch the complete documentation index at: https://docs.prophecy.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Normalize

> Generate multiple output records per input record

Use the Normalize gem to generate multiple output records from each of its input records. This is useful if some records have multiple values in one field, like when a column is populated with arrays.

The following image shows an example table before and after normalization.

<img src="https://mintcdn.com/prophecy-62973bd0/fWeR5LZTItfXqlf2/import-tool/abinitio/abinitio-gems/img/normalize-input-output.png?fit=max&auto=format&n=fWeR5LZTItfXqlf2&q=85&s=fa194a9b8416111a60f07b732b4eadc2" alt="Example input and output" width="2812" height="900" data-path="import-tool/abinitio/abinitio-gems/img/normalize-input-output.png" />

## Parameters

### Expand Condition

| Parameter           | Description                                                                                       |
| ------------------- | ------------------------------------------------------------------------------------------------- |
| Length Expression   | Specifies the number of iterations for each record. This can be an integer or an expression.      |
| Finished Expression | Specifies the number of iterations for each record. Example SQL: `explode(array(0, 1, 2)) AS idx` |
| Finished Condition  | Excludes records from the output table. Example SQL: `idx > size(order_items) - 1`                |

You can either use the **Length Expression** or the **Finished Expression and Finished Condition**. You cannot use all of the parameters simultaneously.

### Index Alias

| Parameter | Description                                                                                                                                                                                        |
| --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Alias     | Defines the name of the index. You can use this alias inside your gem expressions. This will also be the name of the additional output column that shows the index at which a record is generated. |

The index is initialized at `0` and incremented per iteration.

### Output Columns

| Parameter | Description                                                                                                                    |
| --------- | ------------------------------------------------------------------------------------------------------------------------------ |
| Columns   | Lists the columns that will appear in the output table. Example SQL: `element_at(order_items, (idx + 1))['item_name'] AS item` |

In most cases, this is where you will define how the information should be distributed between the new records.

<img src="https://mintcdn.com/prophecy-62973bd0/fWeR5LZTItfXqlf2/import-tool/abinitio/abinitio-gems/img/normalize-output-columns.png?fit=max&auto=format&n=fWeR5LZTItfXqlf2&q=85&s=4e0dcfa956767cd1b30a2edcec040f9c" alt="Normalize output columns" width="2620" height="1508" data-path="import-tool/abinitio/abinitio-gems/img/normalize-output-columns.png" />

### Local and Global Expressions

These expressions are utilized by the Prophecy transpiler. You will not need to add any expressions yourself.
