Skip to main content

EXAMPLE - Flatten an Array

This section describes how to flatten the values in an Array into separate rows in your dataset.

Source:

In the following example dataset, students took the same test three times, and their scores were stored in any array in the Scores column.

LastName

FirstName

Scores

Adams

Allen

[81,87,83,79]

Burns

Bonnie

[98,94,92,85]

Cannon

Chris

[88,81,85,78]

Transformation:

When the data is imported, you might have to re-type the Scores column as an array:

Transformation Name

Change column data type

Parameter: Columns

Scores

Parameter: New type

Array

You can now flatten the Scores column data into separate rows:

Transformation Name

Expand Array into rows

Parameter: Column

Scores

Results:

LastName

FirstName

Scores

Adams

Allen

81

Adams

Allen

87

Adams

Allen

83

Adams

Allen

79

Burns

Bonnie

98

Burns

Bonnie

94

Burns

Bonnie

92

Burns

Bonnie

85

Cannon

Chris

88

Cannon

Chris

81

Cannon

Chris

85

Cannon

Chris

78

Dica

You can use aggregation functions on the above data to complete values like average, minimum, and maximum scores. When these aggregation calculations are grouped by student, you can perform the calculations for each student.