Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Incremental issue.

Hi Team,

I am new to the incremental funtionality in qlikview. Thus stuck in resolving following issue:

I have a table with 20 unique records.

Example: Table 1

Step 1:

Product   Prdname   Price       Updated

101           A                  10          1/06/2015

102           B                   20          2/06/2015

And So on.. Uptil,

120           T                  200        20/06/2015

Step 2: After loading this 20 records I need to perform compare operation for 10 new records. Among these 10 records 4 are same records and remaining are 3 are new and 3 are old records with new dates (3+3=6).

Table 2: 10 records (4 same records, 6 new)

Product   Prdname   Price       Updated

101           A                  10          1/06/2015

102           B                   20          2/06/2015

.

.

121           U                 210         21/06/2015

122           V                 220        22/06/2015

123           W                230        23/06/2015

.

.

.

Step 3: Now I need to delete old records with new dates from 20 records.(17 records remains)

Step 4: Now I will concatenate all the 6 records into 20 record table. Thus the final table should hold 23 records.

Kindly help me generate the above output with respective script.

Thanks in advance !

6 Replies
ramoncova06
Partner - Specialist III
Partner - Specialist III

it would be easier creating a composite key and then working out of that, the asumption here is that the product prdname is your key

OldRecords

load

Product, 

Prdname, 

Price , 

Updated,

Product&'_'&Prdname as %K_ProdKey_Old

from your source

;

NewRecords

load

Product,

Prdname, 

Price , 

Updated,

Product&'_'&Prdname as %K_ProdKey

from your source

;

concatenate(NewRecords)

load

Product,

Prdname, 

Price , 

Updated,

%K_ProdKey_Old as %K_ProdKey

resident OldRecords

where not exists(%K_ProdKey,%K_ProdKey_Old);


drop table OldRecords;


Not applicable
Author

Hi Ramon,

Thanks for your inputs. Once I run the above script, I will get back to you.

Not applicable
Author

Hi Ramon,

I tried implementing as per your suggestions. But in the final table I get only 13 records where I should get 23 records.

Please find the below excel files for reference.

Your kind help would be appreciated.

Table 1:

    

ProductProdNamePriceUpdated
101Watch150$1/1/2015
102Ring300$2/2/2015
103Fruit30$3/3/2015
104Jeans50$4/4/2015
105Pen12$5/5/2015
106Wallet25$6/6/2015
107Shoes70$7/7/2015
108Tshirts100$8/8/2015
109Laptop500$9/9/2015
110Keyboard350$10/10/2015
111Furniture400$11/11/2015
112Socks20$12/12/2015
113Bags85$1/13/2015
114Belts50$1/14/2015
115Trousers200$1/15/2015
116Saree220$1/16/2015
117Books100$1/17/2015
118Bracelet120$1/18/2015
119Caps30$1/19/2015
120Footwears160$1/20/2015

Table 2:

     

ProductProdNamePriceUpdated
101Watch150$1/1/2015     Old
102Ring300$2/2/2015
103Fruit30$3/3/2015
104Jeans50$4/4/2015
105Pen12$20/5/2015   Updated
106Wallet25$26/6/2015
107Shoes70$27/7/2015
108Flowers35$25/6/2015   New
109Jewellery425$26/6/2015
110Key Chains17$27/6/2015

Thanks,

Robin

Not applicable
Author

I tried implementing it again and it works. Thanks again

Not applicable
Author

For simplicity of the code, divide your extraction process into two files

1. Full Load Extract Script.QVW

2. Incremental Load Extract Script.QVW

In Full load extract script, load all the required data from your source into a QVD. Something like below

Table1:

SQL Select * from table;

Store Table1 into Table1.QVD (qvd);

Drop table Table1;

This file has to be reloaded for the first extraction or whenever all the data needs to be extracted from the table for whatever reason.

To do Insert and Update incremental extract, the data should have a column which identifies the time a record has been inserted or updated (In your scenario, it is Updated). And a primary key (Assuming Product primary key in the scenario).

Incremental Load Extract Script should have something like below. This should be reloaded as per the data refresh frequency required.

Max_Date_Previous_Load:

Load Max(Updated) as MaxDatePevLoad

From Table1.QVD (qvd);

Let vMaxDatePrevLoad = Peek('MaxDatePreLoad'); //Putting the Max Date value into a variable

DeltaLoad:

SQL Select * from table Where Updated > $(vMaxDatePrevLoad);

OLD_EXCLUDING_UPDATED:

Concatenate(DeltaLoad) //Concatenating this to DeltaLoad table

Load * From Table1.QVD (qvd)

Where not Exists(Product); //Not loading the Products from QVD which are available in the DeltaLoad

Store DeltaLoad into Table1.QVD (qvd); //Replacing the old QVD

Drop table DeltaLoad;

Not applicable
Author

Hi Kranthikumar,

Thanks a lot for the brief.

Please find the below tables 1 and 2 with details :

Table 1: 20 unique records and

Table 2: 10 records (i.e. 4 records Old order Old date, 3 New record orders and 3 Old order with New dates)

Table 1:

    

ProductProdNamePriceUpdated
101Watch150$1/1/2015
102Ring300$2/2/2015
103Fruit30$3/3/2015
104Jeans50$4/4/2015
105Pen12$5/5/2015
106Wallet25$6/6/2015
107Shoes70$7/7/2015
108Tshirts100$8/8/2015
109Laptop500$9/9/2015
110Keyboard350$10/10/2015
111Furniture400$11/11/2015
112Socks20$12/12/2015
113Bags85$1/13/2015
114Belts50$1/14/2015
115Trousers200$1/15/2015
116Saree220$1/16/2015
117Books100$1/17/2015
118Bracelet120$1/18/2015
119Caps30$1/19/2015
120Footwears160$1/20/2015

Table 2:

     

ProductProdNamePriceUpdated
101Watch150$1/1/2015Old
102Ring300$2/2/2015Old
103Fruit30$3/3/2015Old
104Jeans50$4/4/2015Old
105Pen12$20/5/2015Date  Updated
106Wallet25$26/6/2015Date Updated
107Shoes70$27/7/2015Date Updated
121Flowers35$25/6/2015New
122Jewellery425$26/6/2015New
123Key Chains17$27/6/2015New

Reading the 6 records, Using Where Not Exist will give 17 records (17 because, we need to delete the exisitng 3 old records from the 20 records)

At last, concatenating 6 records (i.e. 3 New record orders and 3 Old order with New dates) to the 17 records, resulting into 23 records

Kindly help me framing a script based on this, I'm stuck. Beacuse what Roman have suggested worked for Records (i.e. Composite key gave me unique records=23) and not for Products (i.e. Need to get record orders=23)

Thanks in advance