Forum Discussion

JTMoneyBest's avatar
JTMoneyBest
Copper Contributor
Apr 05, 2022
Solved

Help transposing rows of data with repeated headings into columns with unique headings

Hello, I always receive raw data in the form of 1x9 rows of numerical data. Each cell of the row is labeled S1, S2, S3, etc. (usually up to S4) but the labels can be repeated and in random order each time. So, if you include the headings, you could say it's a 2x9 table. As an example, there may be two entries labeled S1, three entries labeled S2, two entries labeled S3, and one entry labeled S4. But the next row of data I get will be completely different and in a different order.

 

I would like to be able to automatically transpose this data into ordered columns. I can do this manually but when data volume is high it becomes tedious. In the end, I want 4 columns with headings S1, S2, S3 and S4 with all of the data entries listed underneath.

 

I tried "hlookup" and index / match functions, but it only returns the first data entry with a given label, but I need to collect all data entries with a given common label and transpose it into columns for further analysis.

 

Is there a simple way to do this? Thanks!

 

 

15 Replies

  • Lorenzo's avatar
    Lorenzo
    Silver Contributor
    Please post a picture of what you receive + another one with what you expect, this will definitively clarify things. Thanks
    • JTMoneyBest's avatar
      JTMoneyBest
      Copper Contributor

      Lorenzo 

       

      This is an example of what I receive on the left and what I want to produce on the right.

      • Lorenzo's avatar
        Lorenzo
        Silver Contributor

        JTMoneyBest 

         

        If you have the LAMBDA functions

         

        in K1:

        =SORT(UNIQUE(A1:I1,TRUE),,,TRUE)

         

        in K2:

        =MAKEARRAY(MAX(COUNTIF(A1:I1,K1#)),COLUMNS(K1#),
            LAMBDA(rw,cl,
                IFERROR(INDEX(FILTER(A2:I2,A1:I1=INDEX(K1#,,cl)),1,rw),"")
            )
        )

         

Resources