Qlikview 简明教程
QlikView - Match Function
QlikView 中的 Match() 函数用于将表达式中字符串的值与列中存在的数据值进行匹配。它类似于 SQL 语言中看到的 in 函数。它对于提取包含特定字符串的行很有用,并且还具有 wildmatch() 函数形式的扩展。
The Match() function in QlikView is used to match the value of a string on expression with data value present in a column. It is similar to the in function that we see in SQL language. It is useful to fetch rows containing specific strings and it also has an extension in form of wildmatch() function.
让我们将以下数据作为下面示例的输入文件。
Let us consider the following data as input file for the examples illustrated below.
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
Load Script with Match() Function
以下脚本显示加载脚本,其中读取名为 product_categories.csv 的文件。我们搜索 Product_Line 字段以查找与字符串“Food”和“Sporting Goods”匹配的值。
The following script shows the Load script, which reads the file named product_categories.csv. We search the field Product_Line for values matching with strings 'Food' and 'Sporting Goods'.
Creating Sheet Object
让我们创建一个表框工作表对象,以显示匹配函数生成的数据。转到菜单 Layout → New Sheet Object → Table Box 。将出现以下窗口,我们在其中注明表格的标题,然后选择要显示的所需字段。单击“确定”将在 QlikView 表框中显示 CSV 文件中的数据,如下所示。
Let us create a Table Box sheet object to show the data generated by the match function. Go to the menu Layout → New Sheet Object → Table Box. The following window appears in which we mention the Title of the table and then select the required fields to be displayed. Clicking OK displays the data from the CSV file in the QlikView Table Box as shown below.
Load Script with Wildmatch() Function
wildmatch() 函数是 match() 函数的扩展,在其中我们可以使用通配符作为与所搜索字段中的值匹配的值的字符串的一部分。我们搜索字符串“Off*”、“ ome ”。
The wildmatch() function is an extension of match() function in which we can use wildcards as part of the strings used to match the values with values in the fields being searched for. We search for the strings 'Off*','ome.
Creating Sheet Object
让我们创建一个 Table Box 工作表对象,以显示 wildmatch 函数生成的数据。转到菜单项“布局”→“新建工作表对象”→“表框”。将出现以下窗口,我们在其中注明表格的标题,然后选择要显示的所需字段。单击“确定”将在 QlikView 表框中显示 CSV 文件中的数据,如下所示。
Let us create a Table Box sheet object to show the data generated by the wildmatch function. Go to the menu item Layout → New Sheet Object → Table Box. The following window appears in which we mention the Title of the table and then select the required fields to be displayed. Clicking OK displays the data from the CSV file in the QlikView Table Box as shown below.