Example: Unpivot Stock Vesting Data in a Dataset
This example illustrates how to create an Unpivot stage in a dataset to transpose fields
(columns) of data into rows of data.
You have a CSV file of stock vesting data for your workers. The workers' stock vests in 3
installments, with a different number of shares on each date. The file contains 1
row of data for each worker, and a separate field for each vesting date and the
number of shares that vested on each date.
The CSV file contains these rows and fields:
Name | Vest Date 01 | QTY Vest 01 | Vest Date 02 | QTY Vest 02 | Vest Date 03 | QTY Vest 03 |
|---|---|---|---|---|---|---|
Dominique | 04/01/2020 | 80 | 07/01/2020 | 85 | 10/01/2020 | 92 |
Desmond | 02/01/2021 | 70 | 05/03/2021 | 65 | 08/02/2021 | 79 |
Stacey | 02/01/2021 | 90 | 05/03/2021 | 80 | 08/02/2021 | 90 |
You need to transpose the data so that you have:
- A field that contains all vesting dates for each worker.
- A field that contains the number of shares that vested on each date for each worker.
Create a table by uploading a CSV file using the data in this example. See Steps: Create a Table by File Upload.
Create a derived dataset from the table. See Steps: Create a Derived Dataset.
Security:
Prism Datasets: Manage
domain in the Prism Analytics functional
area.- From theView Dataset Detailsreport of the derived dataset, clickEdit.
- ClickAdd Stage, and selectUnpivot.First, we'll unpivot the 3 date input fields, Vest_Date_01, Vest_Date_02, and Vest_Date_03.
- Click the plus sign next toOutput Valuesso you have a total of 3 pairs of prompts.
- Select these values in theInput FieldsandOutput Valuesprompts:Input FieldsOutput ValuesVest_Date_01Vesting Date 01Vest_Date_02Vesting Date 02Vest_Date_03Vesting Date 03
- InField Names from Input, enter Vesting Schedule.
- InValues from Output, enter Vesting Dates.
- ClickPreviewto see the results of the settings you've made so far.On theOutput Fieldstab, Workday displays the results of the changes you defined in the Unpivot stage. Workday:
- Removes the input fields you selected.
- Displays the 2 new fields using the field names you defined.
- Displays the new rows created using data from the removed input fields. In this example, Workday displays 9 rows total.
- Click the plus sign in the upper right corner of the Unpivot stage panel. Clicking the plus sign creates another group of input fields that you can unpivot into rows.Next, we'll unpivot the 3 quantity input fields, QTY_Vest_01, QTY_Vest_02, and QTY_Vest_03.
- Click the plus sign next toOutput Valuesso you have a total of 3 pairs of prompts.
- In theInput FieldsandOutput Valuesprompts, enter these values:Input FieldsOutput ValuesQTY_Vest_01Quantity Vesting 01QTY_Vest_02Quantity Vesting 02QTY_Vest_03Quantity Vesting 03
- InField Names from Input, enter Quantity Schedule.
- InValues from Output, enter Number of Shares.
- ClickPreviewto see the results of the settings you've made so far.On theOutput Fieldstab, Workday displays the results of the changes you defined in the Unpivot stage.
- ClickDone, and clickSave.
The output of the Unpivot stage contains these rows and fields:
Name | Vesting Schedule | Vesting Dates | Quantity Schedule | Number of Shares |
|---|---|---|---|---|
Dominique | Vesting Date 01 | 04/01/2020 | QTY Vesting 01 | 80 |
Dominique | Vesting Date 02 | 07/01/2020 | QTY Vesting 02 | 85 |
Dominique | Vesting Date 03 | 10/01/2020 | QTY Vesting 03 | 92 |
Desmond | Vesting Date 01 | 02/01/2021 | QTY Vesting 01 | 70 |
Desmond | Vesting Date 02 | 05/03/2021 | QTY Vesting 02 | 65 |
Desmond | Vesting Date 03 | 08/02/2021 | QTY Vesting 03 | 79 |
Stacey | Vesting Date 01 | 02/01/2021 | QTY Vesting 01 | 90 |
Stacey | Vesting Date 02 | 05/03/2021 | QTY Vesting 02 | 80 |
Stacey | Vesting Date 03 | 08/02/2021 | QTY Vesting 03 | 90 |
(Optional) Add a Manage Fields stage after the Unpivot stage to hide the Quantity Schedule
field. In this example, the Quantity Schedule field contains data that is redundant
with the Vesting Schedule field.