2 Replies Latest reply: Feb 15, 2014 12:03 PM by Henric Cronström RSS

    pls give me explination of the script

    manoj kumar

      Table1:

      load * inline [

      ID,name,type,value

      1,A,blue,10

      1,A,yellow,50

      3,C,red,80

      3,C,yellow,60

      4,D,yellow,40

      ];

                                                                      

      Table2:

      generic load *

      resident Table1;

                                                                    --can any body give explination of this script .i am am new to qlik  view

      ResultTable:

      LOAD Distinct ID, name Resident Table1;

       

      FOR i = 0 to NoOfTables()  

        TableList:

        LOAD TableName($(i)) as Tablename AUTOGENERATE 1

        WHERE WildMatch(TableName($(i)), 'Table2.*');

      NEXT i

       

      FOR i = 1 to FieldValueCount('Tablename')

        LET vTable = FieldValue('Tablename', $(i));

        LEFT JOIN (ResultTable) LOAD * RESIDENT [$(vTable)];

        DROP TABLE [$(vTable)];

      NEXT i

       

      Drop Tables Table1, TableList;

        • Re: pls give me explination of the script
          Stefan Wühl

          Please have a look at

           

          qlikviewnotes.blogspot.co.uk/2010/05/use-cases-for-generic-load.html

          • Re: pls give me explination of the script
            Henric Cronström

            Everything after your comment can be deleted. This code is not really necessary. The code before your comment can be simplified to

             

            Table1:

            Generic Load * Inline

            [ID,name,type,value

            1,A,blue,10

            1,A,yellow,50

            3,C,red,80

            3,C,yellow,60

            4,D,yellow,40];

             

            Just run this script and look at the data model. Then you will see that the "Generic" prefix has created one field per color. It has also split the table into one table per color.

             

            All the for-loop in the original script does, is to join the three color tables into one single table - which in most cases isn't necessary.

             

            HIC