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

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
vardhancse
Specialist III
Specialist III

Incremental Load using Single Excel File

Hi,

Have one requirement, could any one please suggest any method to achieve:

Excel file:

1. At point of time one excel file

2. Will append new records

3. May delete old records

4. Will not have any date column

Requirement:

1. Load the excel file

2. Stamp date based on reload time

3. append new records if any without deleting old records even though deleted in excel

4. one single QVD

5. QVD should have all historic data with Date field included

Please find the attached excel and QVW for reference.

13 Replies
Anonymous
Not applicable

Here you go.  I added a date.  This script wouldn't delete records off the QVD based on your Excel file changes.

It's just not built to do that.  If you're losing records there is something else going on.  Like it's not finding your QVD to begin with so it's doing a full reload.  When it does a full reload it will create the QVD with whatever is in the Excel file.

So you'll probably want to step through it and make sure the IF statement I put in is 'catching'.

//Check if QVD exists; if not do full reload

if isnull(QvdCreateTime(EMP.qvd)) THEN

EMP:

LOAD [EMP ID],

     [EMP NAME],

     Designation,

     Department,

     Today() as ImportDate

FROM

Book1.xlsx

(ooxml, embedded labels, table is Sheet1);

Store EMP into EMP.qvd;

Drop Table EMP;                                       //Drop the initial load table after storing QVD

//if QVD does exists only add new records

ELSE

EMP:

LOAD [EMP ID],

     [EMP NAME],

     Designation,

     Department,

     ImportDate

FROM

EMP.qvd

(qvd);

Concatenate(EMP)

//Loading new base file into temp table

EMP_Temp1:

LOAD

   

     [EMP ID],

     [EMP NAME],

     Designation,

     Department,

     Today() as ImportDate

FROM

Book1.xlsx

(ooxml, embedded labels, table is Sheet1)

where not exists([EMP ID]);

Store EMP into EMP.qvd;

Drop Table EMP;  

ENDIF;

Let vEMPRecordsQVD = QvdNoOfRecords('EMP.qvd');//Fetch no of records from initial base QVD

vardhancse
Specialist III
Specialist III
Author

Once will try now thank you

vardhancse
Specialist III
Specialist III
Author

Hi I don't have a primary key/unique field.

In that case can please let me know how to identify new records and append to the historic data

Anonymous
Not applicable

If no unique field then how can you tell what to add?

Normally if there is no single unique field the uniqueness comes from combining multiple fields.

For instance, if your uniqueness comes from EMP_ID and Department you would create a unique key by

something like EMP_ID & '|' & Department as MyUniqueKey.