3 Replies Latest reply: Jun 11, 2011 1:48 PM by Deepak Vadithala RSS

    add column while loading

      Hi all,

       

      I just started working with Qlikview and do have a simple table (three columns) to load.

       

      I don't know if there is a way to do this, but that's why I ask for you help.

       

      The table I use has rows which are identical.

       

      Since I need to be able to have all rows (including identical rows) and want to link this table to another table (with the same amounth of rows offcourse). 

       

      So I thought to add a column with an ID. There is going to be added once in a while a few thousands of rows so I don't want to do this by hand and don't want to have to lookup which ID's are used and which aren't. Thus I prefer to add a column with an automaticaly generated ID.

       

      I think the solution I am looking for looks very much like this: http://community.qlik.com/message/63485#63485

       

      I hope someone can help me.

        • Re: add column while loading
          Deepak Vadithala

          Hi,

           

          How about using RecNo() function in the load script and alias the column name. Please find the explanation below...

           

          RecNo( )

          Returns an integer for the number of the currently read row of the

          input table. The first record is number 1.

           

          Thanks,

          DV

            • Re: add column while loading

              Thanks DV,

               

              This is exactly what I was looking for and lets me have all the (not any more) identical rows

               

              Now I tried to apply this to a crosstable in two ways and both don't work;

               

              1. Crosstable( Vraagnummer, Antwoorden ) LOAD Date(Datum) as Datum, 'ANTW'&RecNo() as AntwoordID,

                   (several columns)

                   FROM...... table location etc.

               

              2. Crosstable( Vraagnummer, Antwoorden,  'ANTW'&RecNo() as AntwoordID ) LOAD Date(Datum) as Datum,

                   (several columns)

                   FROM...... table location etc.

               

              How can I make a table with a column 'AntwoordID', 'Datum', 'Vraagnummer' and a (crosstable)column 'Antwoorden'?