Unpivot (Melt) a Dataframe
Unpivoting is useful when you have a dataset in a wide format that you are looking to convert to a long format. Practically, this means that you have columns where you want to maintain their values, but turn them into rows. This is known as a
For example, imagine you have a dataset with a
product idcolumn, as well as one column per month for a fiscal year:
Feb, etc. The first row in the
Jancolumn contains the quantity of the first product sold in
Jan, the second row contains the quantity of the second product sold in
Unpivoting this dataset would allow you to create a dataframe with three columns: one for the product id, one for the month, and one for the number of that product id sold in that month. This, dataset would make it easier for you to filter down to a specific product and compare the quantity sold across months.
Access the Unpivot Taskpane by Clicking
Dataframes > Unpivot Dataframe. Then, configure your
- 1.Select the dataframe to Unpivot.
- 2.Select the
ID Variables. These columns will be present in the unpivoted dataframe. In our example, you would select the
- 3.Select the
Values. Each column header will go in the variables column, and the column values will go in the values column. In our example, you would select all the month columns.