12 Replies Latest reply: Feb 13, 2014 7:23 AM by Josetxo Amonarriz RSS

    How to transform values in one column to distinct columns (Data from a .csv)

    Alexander Voss

      Hi to all,

       

      i am quite new to QV and was reading for a long time here which helped me a lot already.
      But now i got to a point where i am stuck and couldn't find any solution yet.

       

      The situation:

      I am importing a .csv which got a column which distinct values i want to use as columns, while keeping the other columns.

      Maybe this sample is a bit easier to understand:

       

      original excerpt:

       

      user_idkeyvalue
      1cat1val1
      1cat2val2
      1cat3val3
      2cat1val4
      2cat2val5
      2cat3val6

       

      it want this to be transformed to this:

       

      user_idcat1cat2cat3
      1val1val2val3
      2val4val5val6

       

      there are other columns (like ids, date) in the original i want to keep as well.


      My first thoughts were running throught each line of the original with the help of a switch case/ ifs and checking for the key. but it seems i am running into the problem of concatenating it to the right id/row.

      If think it would be great to have something like 'for each $variable in user_id (column)'. but this doesnt work either.

       

      Any ideas? Do I make an obvious mistake?

       

      Best

      Alex