You are here

QlikView - 2 generic scripts I often use in my development lifecycle

 I use the following 2 generic scripts often in my development live Cycle.

  1. Store and Drop all the Qlikview tables in your Model. This can be applied in the RAW or Functional Data Layer.

let noTabs  = NoOfTables();
set name = '';

for t = 0 to $(noTabs) -1
       let tab = TableName( $(t) );
       store $(tab) into $(tab).qvd;
       let name = '$(name)' & ',' & '$(tab)';
next t;

let name = mid(replace('$(name)',',',      chr(39)&','&chr(39)) & chr(39),3,1000);

for each tabname in $(name)
       drop table '$(tabname)';
next tabname;

  1. Extracting the exact same tables out of different databases- you need them to be consolidated in Tables with a field Identifier

  2. FOR EACH COMPANY IN 'COMPANY1','COMPANY2','COMPANY3'

OLEDB CONNECT TO $(COMPANY);  //SETUP CONNECTION STRING REPLACING COMPANY/DATABASENAME WITH VARIABLE

              //DATA
              
              FOR EACH File IN 'TABLE1','TABLE2' ,'TABLE3','TABLE4'
              
                     $(File):
                     
                     LOAD *,
                     '$(COMPANY)' AS COMPANY,
                     '$(File)'            AS $(File)
                     
                     ;
                     SQL SELECT *
                     FROM dbo.$(File);
                     
              NEXT File
NEXT COMPANY