Skip to main content
Solved

Pivot rows to columns

  • March 19, 2020
  • 9 replies
  • 968 views

nedwaterman
Contributor
Forum|alt.badge.img+9

Why isn't this easier in FME? I've tried lots of examples on the Hub, but can't get any of them to work. The Attribute Pivoter is difficult to use and never gives me the results I need. I can perform this very easily in SQL.

 

I'm trying to turn my rows Vxx into columns with the value of Litres, grouped by all the other rows. Any idea how I can achieve this? Thanks in advance!

 

Best answer by ebygomm

@nedwaterman Example workspace attached - it's in 2019.2 - it'll warn about the workspace not being compatible but should open correctly

pivot.fmwt

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

9 replies

ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3422 replies
  • March 19, 2020

Can you give an example of what the output should look like?


nedwaterman
Contributor
Forum|alt.badge.img+9
  • Author
  • Contributor
  • 69 replies
  • March 19, 2020

Certainly - find it attached!example.xlsx


ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3422 replies
  • March 19, 2020

I nearly always use pivot data by using the value of an attribute to create a new attribute with that name, then aggregate and merge attributes and expose the newly created attributes

You can import the values from the period column in the original input in the AttributeExposer

Gives this output


ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3422 replies
  • March 19, 2020

You can use the attribute pivoter though as well, you still need to expose the attributes if you want to see them on the canvas

The attribute pivoter does set up a schema for you which makes it slightly more straightforward to write th data out dynamically without exposing the attributes


nedwaterman
Contributor
Forum|alt.badge.img+9
  • Author
  • Contributor
  • 69 replies
  • March 19, 2020

I nearly always use pivot data by using the value of an attribute to create a new attribute with that name, then aggregate and merge attributes and expose the newly created attributes

You can import the values from the period column in the original input in the AttributeExposer

Gives this output

That would be perfect. Would you mind sending me your workflow? I'm on 2019.1.

 

Thank you very much for taking the time to help me with this - it's been driving me mad!


ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3422 replies
  • Best Answer
  • March 19, 2020

@nedwaterman Example workspace attached - it's in 2019.2 - it'll warn about the workspace not being compatible but should open correctly

pivot.fmwt


nedwaterman
Contributor
Forum|alt.badge.img+9
  • Author
  • Contributor
  • 69 replies
  • March 19, 2020

You can use the attribute pivoter though as well, you still need to expose the attributes if you want to see them on the canvas

The attribute pivoter does set up a schema for you which makes it slightly more straightforward to write th data out dynamically without exposing the attributes

Thanks very much ebgygomm - I've used this approach and it works beautifully. You've saved me from insanity!


nedwaterman
Contributor
Forum|alt.badge.img+9
  • Author
  • Contributor
  • 69 replies
  • March 19, 2020

@nedwaterman Example workspace attached - it's in 2019.2 - it'll warn about the workspace not being compatible but should open correctly

pivot.fmwt

Thank you - you have been a great help!


smclaugh1
Contributor
Forum|alt.badge.img+5
  • Contributor
  • 14 replies
  • September 29, 2022

@ebygomm​ 

Thanks for the great pivot examples, these are perfect.