Skip to content

Fold multiple columns

Description

The Fold Multiple Columns activity transforms multiple column values into a key-value format. It converts wide-form data (multiple columns) into long-form data (rows), where each selected column becomes a row entry with two new fields: one for the original column name (label) and another for the value.

Use Case
This is useful when reshaping data for charting, normalization, or when preparing data for machine learning models that expect long-form inputs.


Input

TypeDescription
DataDataset with multiple columns to fold.

Output

TypeDescription
Transformed DataDataset with folded columns converted into row-based values.

Configuration Fields

Field NameRequiredDescription
UseRegexNoEnable to match columns dynamically using a regular expression.
Pattern To MatchConditionalRegex pattern to match column names. Visible only if UseRegex is enabled.
Columns To FoldYes (if UseRegex is disabled)List of specific columns to fold.
Folded ColumnYesName of the new column that stores the original column names (labels).
Values ColumnYesName of the new column that stores the values from the folded columns.

Sample Input

IDNameQ1Q2Q3
1AliceYesNoYes
2BobNoYesNo

Sample Configuration

FieldValue
Columns To FoldQ1, Q2, Q3
Folded ColumnQuestion
Values ColumnResponse

Sample Output

IDNameQuestionResponse
1AliceQ1Yes
1AliceQ2No
1AliceQ3Yes
2BobQ1No
2BobQ2Yes
2BobQ3No