开发手册 欢迎您!
软件开发者资料库

QlikView - 增量负载

QlikView增量加载 - 从简单和简单的步骤学习QlikView,从基本到高级概念,包括简介,安装,QlikView数据加载,QlikView报告界面,QlikView数据转换,QlikView数据模型,QlikView数据分析和重要资源。

随着QlikView文档数据源中的数据量增加,加载文件所需的时间也会增加,这会降低分析过程的速度.最小化加载数据所花费的时间的一种方法是仅加载源中的新记录或更新的记录.将源中的新记录或已更改记录加载到QlikView文档中的概念称为增量加载.

要从源识别新记录,我们使用每行的顺序唯一键或日期时间戳.这些唯一键或数据时间字段的值必须从源文件流向QlikView文档.

让我们考虑以下包含零售商店中产品详细信息的源文件.将其保存为本地系统中的.csv文件,QlikView可以访问该文件.在一段时间内,会添加更多产品,并对某些产品的描述进行更改.

Product_Id,Product_Line,Product_category,Product_Subcategory1,Sporting Goods,Outdoor Recreation,Winter Sports & Activities2,"Food, Beverages & Tobacco",Food Items,Fruits & Vegetables3,Apparel & Accessories,Clothing,Uniforms4,Sporting Goods,Athletics,Rugby5,Health & Beauty,Personal Care6,Arts & Entertainment,Hobbies & Creative Arts,Musical Instruments7,Arts & Entertainment,Hobbies & Creative Arts,Orchestra Accessories8,Arts & Entertainment,Hobbies & Creative Arts,Crafting Materials9,Hardware,Tool Accessories,Power Tool Batteries10,Home & Garden,Bathroom Accessories,Bath Caddies11,"Food, Beverages & Tobacco",Food Items,Frozen Vegetables12,Home & Garden,Lawn & Garden,Power Equipment

将数据加载到QlikView

我们将使用脚本编辑器加载上述CSV文件(通过选择Table Files选项控制+ E),如下所示.在这里,我们还将数据保存到本地系统的QVD文件中.将QlikView文档另存为.qvw文件.

incr_laod_create_qvd

验证数据已加载.

我们可以通过创建名为表格框的工作表对象来检查加载到QlikView文档的数据.这可以在布局菜单和新工作表对象子菜单中找到.

 table_box_option

创建表格布局

选择表格框表格对象后,进入下一个屏幕,即用于选择要创建的表中的列及其位置.我们选择以下列及其位置,然后单击"完成".

Incr_load_product_details

查看现有数据

下面的图表显示了上一步中列出的数据.

incremental_load_data

更新源数据

让我们将以下三个记录添加到源数据中.在这里,产品ID是唯一的数字,代表新的记录.

13,Office Supplies,Presentation Supplies,Display14,Hardware,Tool Accessories,Jigs15,Baby & Toddler,Diapering,Baby Wipes

增量加载脚本

现在,我们编写脚本以仅从源中提取新记录.

// Load the data from the stored qvd.Stored_Products:LOAD Product_Id,      Product_Line,      Product_category,      Product_SubcategoryFROM[E:\Qlikview\data\products.qvd](qvd);//Select the maximum value of Product ID.Max_Product_ID:Load max(Product_Id) as MaxIdresident Stored_Products;//Store the Maximum value of product Id in a variable.Let MaxId = peek('MaxId',-1); drop table Stored_Products;//Pull the rows that are new. NewProducts:LOAD Product_Id,Product_Line, Product_category,Product_Subcategory from [E:\Qlikview\data\product_categories.csv] (txt, codepage is 1252, embedded labels, delimiter is ',', msq) where Product_Id > $(MaxId); //Concatenate the new values with existing qvd.ConcatenateLOAD Product_Id,Product_Line, Product_category,      Product_SubcategoryFROM [E:\Qlikview\data\products.qvd](qvd);//Store the values in qvd.store NewProducts into [E:\Qlikview\data\products.qvd](qvd);

上述脚本仅提取新记录,这些记录被加载并存储到qvd文件中.当我们看到带有新产品ID 13,14和15的记录时.

incremental_load_final_data