Skip to main content
Solved

Convert data in rows to columns using field values as the column name

  • August 8, 2022
  • 4 replies
  • 537 views

I have lab data that is reported in rows, one row for each analyte for each sample.

I need to create a single record for each sample, with the analyte values as columns in the record - build a single record of analyte values for each sample.imageto this:

image

Best answer by ebygomm

Thanks Mark, that article explains transforming columns into rows. I want to do the opposite - build columns out of rows using a unique ID.

First you will want to add a column that gives the column names you want to use, e.g. I presume the value alongside Perfluorobutanoic acid (PFBA) will want to end up in a column called PFBA.

Then you'll want to create a new attribute using the value of AnalyteName and setting it's value to the appropriate column (Result?)

imageThe new attributes will be created but hidden at this point, so you'll need to expose them using an AttributeExposer. Finally you need to aggregate the data to a single row, ensuring that you select Merge Incoming Attributes under accumulation mode. If you have data for multiple samples you will need to choose an appropriate attribute to group by here.

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.

4 replies

Forum|alt.badge.img+2

@vcarr2005​ Have a look at the article Transpose a Table Using FME.


  • Author
  • August 10, 2022

Thanks Mark, that article explains transforming columns into rows. I want to do the opposite - build columns out of rows using a unique ID.


ebygomm
Influencer
Forum|alt.badge.img+46
  • Influencer
  • Best Answer
  • August 10, 2022

Thanks Mark, that article explains transforming columns into rows. I want to do the opposite - build columns out of rows using a unique ID.

First you will want to add a column that gives the column names you want to use, e.g. I presume the value alongside Perfluorobutanoic acid (PFBA) will want to end up in a column called PFBA.

Then you'll want to create a new attribute using the value of AnalyteName and setting it's value to the appropriate column (Result?)

imageThe new attributes will be created but hidden at this point, so you'll need to expose them using an AttributeExposer. Finally you need to aggregate the data to a single row, ensuring that you select Merge Incoming Attributes under accumulation mode. If you have data for multiple samples you will need to choose an appropriate attribute to group by here.


  • Author
  • August 10, 2022

Thank you, this is exactly what I needed.