Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space DEV and version next

...

productNameproductColorproductSize
WhizbangredM
Whizbangred, blueL
WhizbanggreenM
BangwhizredS
BangwhizblueM
BangwhizredS

TranformTranformation:

After you have created a header, if necessary, add the following transformtransformation:

d-

...

trans
RawWrangletrue
Typestep
WrangleTextunpivot col:productColor
p01NameColumns
p01ValueproductColor
SearchTermUnpivot columns

Results:

productNameproductSizekeyvalue
WhizbangMproductColorred
WhizbangLproductColorred, blue
WhizbangMproductColorgreen
BangwhizSproductColorred
BangwhizMproductColorblue
BangwhizSproductColorred

...

  • Since the value is treated as a string, the value red, blue is treated as one value.

Now, edit the transform transformation you just added. Replace it with the following, which includes the productSize key as part of the transformtransformation:

d-

...

trans
RawWrangletrue
Typestep
WrangleTextunpivot col:productColor,productSize
p01NameColumns
p01ValueproductColor,productSize
SearchTermUnpivot columns

Results:

productNamekeyvalue
WhizbangproductColorred
WhizbangproductSizeM
WhizbangproductColorred, blue
WhizbangproductSizeL
WhizbangproductColorgreen
WhizbangproductSizeM
BangwhizproductColorred
BangwhizproductSizeS
BangwhizproductColorblue
BangwhizproductSizeM
BangwhizproductColorred
BangwhizproductSizeS

...

Example - Basic Pivot with groupEvery

Tranformation:

From the previous example, modify the unpivot transform to be the following:

d-

...

trans
RawWrangletrue
Typestep
WrangleTextunpivot col:productColor,productSize groupEvery:2
p01NameColumns
p01ValueproductColor,productSize
p02NameGroup size
p02Value2
SearchTermUnpivot columns

Results:

productNamekey1value1key2value2
WhizbangproductColorredproductSizeM
WhizbangproductColorred, blueproductSizeL
WhizbangproductColorgreenproductSizeM
BangwhizproductColorredproductSizeS
BangwhizproductColorblueproductSizeM
BangwhizproductColorredproductSizeS

...