如何在qlikview中执行增量加载

时间:2014-09-25 05:37:15

标签: load qlikview

我有一个交易表,每天都会添加新记录。我想构建一个只加载增量数据的QVD文件。

1 个答案:

答案 0 :(得分:0)

您需要一个日期(时间)列来标识新记录。

然后你可以这样做:

///$tab Main
SET ThousandSep='.';
SET DecimalSep=',';
SET MoneyThousandSep='.';
SET MoneyDecimalSep=',';
SET MoneyFormat='#.##0,00 €;-#.##0,00 €';
SET TimeFormat='hh:mm:ss';
SET DateFormat='DD.MM.YYYY';
SET TimestampFormat='DD.MM.YYYY hh:mm:ss[.fff]';
SET MonthNames='Jan;Feb;Mrz;Apr;Mai;Jun;Jul;Aug;Sep;Okt;Nov;Dez';
SET DayNames='Mo;Di;Mi;Do;Fr;Sa;So';

set vSourceDir = 'C:\devel\qlikview\2013\Incremental_Load\';

///$tab Initial
// Initial data load

/*

Sales:
LOAD OrderId, 
     ProductId, 
     CustomerId, 
     Amount, 
     date(Date_updated) as Date_updated
FROM
$(vSourceDir)Data.xlsx
(ooxml, embedded labels, table is Orders);

STORE Sales INTO $(vSourceDir)sales.qvd (qvd);

*/
///$tab Load from QVD
// load sales.qvd

Sales:
LOAD OrderId, 
     ProductId, 
     CustomerId, 
     Amount, 
     date(Date_updated) as Date_updated
FROM
$(vSourceDir)sales.qvd
(qvd);

Sort_Sales:
LOAD * 
Resident Sales
Order By Date_updated;

LET vLastUpdateDate = date(Peek('Date_updated', -1, 'Sort_Sales'));


DROP TABLE Sales;

///$tab Perform Incremental load
// load only new (incremental) data

Incremental:
NoConcatenate
LOAD OrderId, 
     ProductId, 
     CustomerId, 
     Amount, 
     date(Date_updated) as Date_updated
FROM
$(vSourceDir)Data.xlsx
(ooxml, embedded labels, table is NewOrders)
where  date(Date_updated) >= '$(vLastUpdateDate)';



///$tab Update QVD
// load data from qvd without the records that where changed

Concatenate
LOAD OrderId, 
     ProductId, 
     CustomerId, 
     Amount, 
     date(Date_updated) as Date_updated
FROM 
$(vSourceDir)sales.qvd (qvd)
where not exists(OrderId);

STORE Incremental INTO $(vSourceDir)sales.qvd;

以下是解释https://www.youtube.com/watch?v=UkKTmnKSNQo

HTH