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

# Melt (Wide to Long)

> Convert a wide-format dataset to long format, collapsing value columns into rows under a new variable column.

**Melt** goes from wide to long: several value columns collapse into two — one holding the former column names, one holding the values. It is the inverse of [Unstack (Long to Wide)](/steps/unstack-dataset), which is where the shared long-versus-wide diagram lives.

## Configuration

Define:

* The name of the column that will host the former column names — the tickers, in the example below.
* The name of the column that will hold the values.
* Which columns should be melted. Uncheck the ones that should stay as columns.

<Frame>
  <img src="https://mintcdn.com/alphacastio/ttF_U-V9HDrmrPbo/images/steps/melt-step-config.png?fit=max&auto=format&n=ttF_U-V9HDrmrPbo&q=85&s=a029241b6d14ef52821a91927b7cb631" alt="Configuring the Wide to Long step" width="2560" height="1221" data-path="images/steps/melt-step-config.png" />
</Frame>

The result carries one row per combination of the retained entities and the melted variable:

<Frame>
  <img src="https://mintcdn.com/alphacastio/ttF_U-V9HDrmrPbo/images/steps/melt-result.png?fit=max&auto=format&n=ttF_U-V9HDrmrPbo&q=85&s=5d78e7724386dbcc8fbfe6293f94de0c" alt="The resulting long-format dataset" width="1032" height="761" data-path="images/steps/melt-result.png" />
</Frame>

<Note>
  Long format is usually what you want before [Regroup entities](/steps/regroup-entities) or before publishing a dataset that other people will filter by entity.
</Note>

## Next steps

<CardGroup cols={2}>
  <Card title="Unstack (Long to Wide)" icon="arrows-left-right" href="/steps/unstack-dataset">
    The inverse operation, with the full worked example.
  </Card>

  <Card title="Regroup entities" icon="layer-group" href="/steps/regroup-entities">
    Aggregate once the data is in long format.
  </Card>
</CardGroup>
