Qlikview教程

QlikView 匹配函数

QlikView 中的 Match() 函数用于将表达式中的字符串值与列中存在的数据值进行匹配。它类似于我们在 SQL 语言中看到的 in 函数。获取包含特定字符串的行很有用,它还有一个以 wildmatch() 函数形式的扩展。
让我们考虑以下数据作为下图示例的输入文件。
Product_Id,Product_Line,Product_category,Product_Subcategory
1,Sporting Goods,Outdoor Recreation,Winter Sports & Activities
2,Food, Beverages & Tobacco,Food Items,Fruits & Vegetables
3,Apparel & Accessories,Clothing,Uniforms
4,Sporting Goods,Athletics,Rugby
5,Health & Beauty,Personal Care
6,Arts & Entertainment,Hobbies & Creative Arts,Musical Instruments
7,Arts & Entertainment,Hobbies & Creative Arts,Orchestra Accessories
8,Arts & Entertainment,Hobbies & Creative Arts,Crafting Materials
9,Hardware,Tool Accessories,Power Tool Batteries
10,Home & Garden,Bathroom Accessories,Bath Caddies
11,Food, Beverages & Tobacco,Food Items,Frozen Vegetables
12,Home & Garden,Lawn & Garden,Power Equipment
13,Office Supplies,Presentation Supplies,Display
14,Hardware,Tool Accessories,Jigs
15,Baby & Toddler,Diapering,Baby Wipes

使用 Match() 函数加载脚本

以下脚本显示了加载脚本,该脚本读取名为 product_categories.csv 的文件。我们在字段 Product_Line 中搜索与字符串 'Food' 和 'Sporting Goods' 匹配的值。
Matched_func_script

创建工作表对象

让我们创建一个 Table Box 工作表对象来显示匹配函数生成的数据。转到菜单 布局→新建工作表对象→表格框。出现以下窗口,我们在其中提及表的标题,然后选择要显示的必填字段。单击"确定"会在 QlikView 表格框中显示来自 CSV 文件的数据,如下所示。
Matched_func_data

使用 Wildmatch() 函数加载脚本

wildmatch() 函数是 match() 函数的扩展,其中我们可以使用通配符作为字符串的一部分,用于将值与要搜索的字段中的值进行匹配。我们搜索字符串 'Off*','*ome*。
wildmatch_script

创建工作表对象

让我们创建一个 Table Box 工作表对象来显示由 Wildmatch 函数生成的数据。转到菜单项布局 → 新建工作表对象 → 表格框。出现以下窗口,我们在其中提及表的标题,然后选择要显示的必填字段。单击"确定"会在 QlikView 表格框中显示来自 CSV 文件的数据,如下所示。
wildmatch_data
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4