Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
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
Once will try now thank you
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
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.