# Unstack

In this document, you’ll learn how to use the **Unstack** transformation in Astera Dataprep to convert values from a single column into multiple columns, making it easier to compare data side by side.

Suppose you have a dataset containing education-related statistics for multiple countries, with columns for **Country**, **ISO\_Code**, **Year**, and **LAYS**. Each country has separate rows for different years. For example, 2017, 2018, and 2020.

1. To unstack data in Astera Dataprep, click on the *Transform* option in the toolbar and select *Unstack* from the drop-down.

<figure><img src="/files/FW7onYg1G6nroaDO880C" alt=""><figcaption></figcaption></figure>

2. Once selected, the *Recipe Configuration – Unstack* panel will open.

<img src="/files/a9qsjD3TEIYBSHZsL3FT" alt="" width="388">

* **Group Count:** Check this option if you manually define the number of input groups in your dataset.
* **Number of Input Groups:** The number of times your repeating values appear for each unique Key.
* Unstack Options:
  * **Key**: Columns that uniquely identify each record (e.g., *Country*, *ISO\_Code*).
  * **Input**: Columns that hold the values you want to unstack (e.g., *LAYS*).

*Example:* Setting number of input groups to 3 (for years 2017, 2018, and 2020) with Country and ISO\_Code as *Key* and *LAYS* as Input will unstack values into three new columns (LAYS1, LAYS2, LAYS3).

![](/files/eiIQ4P5wU1R2pvetetOA)

* **Pivot:** Check this option when you want to unstack data based on a category or driver values (e.g., Year), creating separate columns for each value.

<img src="/files/DfXKOUgpjJ8quyM71uDX" alt="" width="395">

* Unstack Options:
  * **Key**: Columns that uniquely identify each record (e.g., *Country*, *ISO\_Code*).
  * **Input**: Columns that hold the values you want to unstack (e.g., *LAYS*).
  * **Pivot**: Column containing categories or drivers (e.g., *Year*).
* Driver Values: You also need to provide the driver values (e.g., 2017, 2018, 2020). These can be entered manually or fetched using *Auto Fill*.

3. Once you are done with your configurations, click <img src="/files/87Jq7LNPIYwtUvUMXvZK" alt="" data-size="line"> *Apply*.

*Example:* Setting *Country* and *ISO\_Code* as Key, *LAYS* as Input, and *Year* as Pivot with driver values *2017, 2018, 2020* will generate separate columns named LAYS\_2017, LAYS\_2018, and LAYS\_2020.

![](/files/zj1zFBrgmZz4qEYgFsuV)

{% hint style="info" %}
**Tip:** You can also ask in Chat something like *“Unstack the LAYS column by Year so that each year becomes its own column”*, and Dataprep will configure the transformation for you automatically.
{% endhint %}

![](/files/whNq84JP95WEHXOkX7jF)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.astera.com/dataprep/transforming-data/unstack.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
