Data Reshape

Convert data between Wide format and Long format. Use this to restructure data layouts to match the requirements of different analysis methods.

Basic Usage

Opening Reshape

Select Data > Reshape (Wide/Long)... from the menu bar to open a new Reshape tab.

Reshape tab basic view

The screen consists of a settings panel on the left and a preview area on the right. Switch between Wide to Long and Long to Wide using the tabs at the top of the settings panel.

Sample Data Used in This Page

The examples on this page use a grades dataset (grades.csv) containing test scores for 5 students. Each subject has its own column in Wide format.

namemathscienceenglish
Alice908588
Bob759280
Carol887895
Dave928882
Eve789590

Wide to Long

Collapse multiple columns into a single column (unpivot). Each row expands into multiple rows.

For example, convert the grades data above into a "one row per subject" format. The result looks like this:

namesubjectscore
Alicemath90
Alicescience85
Aliceenglish88
Bobmath75
.........

Parameters

Dataset - Select the dataset to transform.

ID Columns - Select columns to keep as-is. In the example above, name is the ID column. Optional.

Value Columns - Select columns to unpivot. In the example above, math, science, and english. At least one column is required.

Variable Column Name - Name for the new column that holds the original column names. Defaults to variable.

Value Column Name - Name for the new column that holds the values. Defaults to value.

Click Preview to see the result.

Wide to Long conversion preview

Long to Wide

Expand key-value data into columns (pivot). Multiple rows are collapsed into a single row.

Use this for the reverse of Wide to Long, or to arrange aggregated results into a tabular layout.

Parameters

Dataset - Select the dataset to transform.

ID Columns - Select columns that identify each row. Optional.

Variable Column - Select one column whose unique values become new column names.

Value Column - Select one column whose values fill the new columns.

Long to Wide conversion preview

Preview and Save

Click Preview to check the result. The preview shows up to 100 rows along with the total row and column counts.

When the result looks correct, click Save as Dataset. Enter a dataset name and save to create a new derived dataset.

Notes

  • If value columns have mixed data types in Wide to Long, the value column is converted to string type
  • In Long to Wide, duplicate combinations of ID columns and variable column cause an error. Add more ID columns to uniquely identify each row
  • In Long to Wide, missing combinations result in null values

See also