Skip to main content
Solved

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


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

vcarr2005 wrote:

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.

View original
Did this help you find an answer to your question?

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+31
  • Influencer
  • Best Answer
  • August 10, 2022
vcarr2005 wrote:

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.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings