A fold transformation reshapes the data by unpivoting it.
Suppose a table with variables, column1, column2, category1, and category2.
Folding column1 and column2 by category1 results in key, value, category1, and category2 like below.
Before
column1
column2
category1
category2
1
2
‘A’
‘a’
3
5
‘B’
‘b’
4
6
‘C’
‘c’
After
key
value
category1
category2
column1
1
‘A’
‘a’
column2
2
‘A’
‘a’
column1
3
‘B’
‘b’
column2
5
‘B’
‘b’
column1
4
‘C’
‘c’
column2
6
‘C’
‘c’
Fold properties
Property
Type
Description
fold
Array[String]
(Required) An array of field names to fold.
by
String
(Required) A nominal field to group by.
exclude
Boolean
(Optional, default: false) Whether to drop other fields (not specified by fold and by).
as
Array[String, length=2]
(Optional, default: ['key', 'value']) New field names for folded variables.
Usage pattern
JSON
JavaScript
Extended pattern with a repeat channel
Using fold with a repeat channel enables expressing intervals repeated over a field.