4 Replies Latest reply: Dec 20, 2012 4:50 AM by Mohit Sharma RSS

    How can we insert row into table dynamically .

      Hi

           I want to insert row in table dynamically.

          My scenario is like that:

      I have one table tabl1:

       

      Date,           field1, field2, filed3, count

      02-12-2012,  A ,        B    ,  C,   200

      02-12-2012,  X ,       Y      ,   Z,    300

      03-12-2012,  A ,      B       ,  C,    400

      04-12-2012,  X ,       Y     ,    Z ,      500         

      05-12-2012,  X        ,Y      ,  Z         600

      02-12-2012,  A ,      B       ,  C,      600

       

      Here we always consider  1st date will always have all keys(field1& field1& field1). These all keys should be available for all date if it is not there then

      we  have to insert new row in table with same key and value for that date.

      Here in this example date 02-12-2012 have two key ABC and XYZ .

      Now we will  move to next date(03-12-2012) and finding here we have only one key ABC and XYZ is missing.

      So for this date we ll insert new row with previous date field value key.

      In above table we ll insert one row like this for XYZ key.

      03-12-2012,  X     ,Y     ,  Z,              300

       

      In the same way for  date 04-12-2012 , we ll insert one more row like this:

      04-12-2012,  A     ,B     ,   C, 400

       

      This process ll follow for each date.

      Finally Output table ll be like this:

       

      Date,           field1, field2, filed3, count

      02-12-2012,  A ,      B       ,  C,   200

      02-12-2012,  X ,      Y      ,   Z,     300

      03-12-2012,  A      ,B       ,  C,     400

      03-12-2012,  X        ,Y     ,  Z,      300(newly added)

      04-12-2012,  X ,     Y     ,    Z ,      500    

      04-12-2012,  A     ,B     ,   C,        400(newly added)

      05-12-2012,  X ,     Y     ,    Z ,       500

      05-12-2012,  A     ,B     ,   C,         400(newly added)

       

      How to do this in QlikView script.

       

       

        

       

       

      Thanks and Regards

      Rahul Rao

        • Re: How can we insert row into table dynamically .
          Vishwaranjan Kumar

          i think for this ,

          firstly in your excel file write according to this, and by the use of input box you can insert row in table.

          datefield1field2
          2/5/201228
          2/5/201259
          3/6/201264
          3/6/2012786
          4/6/2012

          10/12/2012

          hope it will help you

            • Re: How can we insert row into table dynamically .

              Hi Vishwaranjan

                                       Thanks for reply!!!!,

                                       But this i want to do in script itself since i have data in qvd.

                                        Can we do this in script level?

                • Re: How can we insert row into table dynamically .
                  Vishwaranjan Kumar

                  hi rahul

                  use inline function and add row dynamically

                   

                  step1- now go to script then go to insert tab  load statement--> from inline

                             then you must write the unique field name  where you want to add the field values

                  example       mat id      data          price

                                        h101          a              

                                        h102          x

                  step 2-take a input box wthin it add two variables   name =  x

                                                                                                   value=  20

                  • Re: How can we insert row into table dynamically .
                    Mohit Sharma

                    hey you can add fields  value in script also.

                    using load * inline function.fot this go in  edit script then insert tab and that go to load statement from inline

                    there's you add values but must be know that write the same field name which are you sing in database to make a key.. and then add values.

                    hope this will helps you....