QlikView Keep Functions – Left, Right, Inner Keep Function

1. Objective – QlikView Keep Functions

After understanding the QlikView Join functions, let us move further and learn about another function called QlikView Keep Function. Moreover, we will discuss the types of Keep functions in QlikView: left, right, inner functions with the example.

So, let us explore the Keep function with example.

QlikView Keep Functions - Left, Right, Inner Keep Function in QlikView

QlikView Keep Functions – Left, Right, Inner Keep Function in QlikView

2. What is QlikView Keep Function?

The QlikView Keep Function is used to merge two or more data sets together into one keeping the original data files intact in memory. Here it differs from Join as when you apply the join function to combine two data sets, the software loads and creates a single combined data set as a result. It does not retain the original files as it is in the memory which the Keep function does.

Even after applying QlikView Keep function in the data files, you get the option whether you want to choose fields from the old tables or the new combined one. So in a way, the keep function is not practically joining the data sets but is just reducing repetitive data load from the data sets by keeping them in the memory as the same field value. So as to avoid unnecessary explicit or clear data combining and leaving some room for manipulation and making the merging of data sets a little flexible.

Do you know How to Create QlikView Dashboard?

We will be illustrating QlikView Keep Function through sample data files in the upcoming section. One more evident difference between Keep and Join is that join has an OUTER type of join where you get to join and see two or more tables into one full table. Such an Outer type is not available in Keep.

QlikView Quiz

3. Types of Keep Function in QlikView

We have explained three different kinds of QlikView Keep Function using two data sets given below.

QlikView Keep Functions Example

Table1:-

Product_Id,Product_Type,Product_name

pr5,Health & Beauty,Body Lotion

pr6,Arts & Entertainment,Musical Instruments

pr7, Arts & Entertainment, Orchestra Accessories

pr8,Arts & Entertainment,Crafting Materials

pr9, Hardware, Power Tool Batteries

pr10,Home & Garden,Bath Caddies

pr11,”Food, Beverages & Tobacco”,Frozen Vegetables

pr12,Home & Garden,Power Equipment

pr13, Home & Garden, Water Hose

pr14, Health & Beauty, Aloe vera Gel

pr15,Health & Beauty,Face pack

Let’s revise the Architecture of QlikView

Table2:

Product_Id,Product_Type

pr1,Sporting Goods

pr2,”Food, Beverages & Tobacco”

pr3,Apparel & Accessories

pr4,Sporting Goods

pr5,Health & Beauty

pr6,Arts & Entertainment

pr7,Arts & Entertainment

pr8,Arts & Entertainment

These files were loaded into QlikView script (opened by CTRL+E) where we will add the Keep function between two LOAD commands.

a. QlikView Inner Keep

Inner Keep function in QlikView, is the same as the Inner Join function as it fetches the common data values between the two tables (Left and Right table).

Name:
LOAD Product_Id,
     Product_Type,
     Product_name
FROM
[C:\Users\HP\Desktop\Dataflair\productname.csv]
(txt, codepage is 1252, embedded labels, delimiter is ',', msq);

INNER KEEP(Name)
LOAD Product_Id,
     Product_Type,
FROM
[C:\Users\HP\Desktop\Dataflair\Product List.csv]
(txt, codepage is 1252, embedded labels, delimiter is ',', msq);
QlikView Keep Functions

QlikView Keep Functions – QlikView Inner Keep

Although, when you load the files into the script, save and reload it, you get an option to choose which table do you want to select fields from while creating the Table Box or any sheet object for that matter.

Let’s Read about QlikView Table (Creating Cross, Straight, Pivot, Mapping Tables)

QlikView Keep Functions

QlikView Keep Functions – QlikView Inner Keep

In the screenshot given above, the tab ‘Show Fields From Table’ has all the three kinds (two original and one combined) of table loaded. The current selection made here is the ‘Product List’ table and as you can see in the ‘Fields Displayed’ box, only the fields present in Product List table are available for selection.

QlikView Keep Functions

QlikView Keep Functions – QlikView Inner Keep

This time we have changed the selection and have another original table ‘Name’ that has the product name field added. The display box shows two key fields and one added field Product_name also.

QlikView Keep Functions

QlikView Keep Functions- QlikView Inner Keep

Now, to see the merged table, we have selected ‘All Tables’ option which shows the field from all the tables present in QlikView’s memory. This will be the table created from the function KEEP.

Also, See – Features of QlikView Script Editor

QlikView Keep Functions

QlikView Keep Functions- QlikView Inner Keep

These are separate table boxes created by being able to choose fields. from individual data files. Here, the inner keep takes only the data values (ID 5 to 8) that were common in both data sets.

b. QlikView Left Keep

The Left Keep fetches all the data values from the left table (Productname) and only the common values from the right table.

Name:
LOAD Product_Id,
     Product_Type,
     Product_name
FROM
[C:\Users\HP\Desktop\Dataflair\productname.csv]
(txt, codepage is 1252, embedded labels, delimiter is ',', msq);

LEFT KEEP(Name)
LOAD Product_Id,
     Product_Type,
FROM
[C:\Users\HP\Desktop\Dataflair\Product List.csv]
(txt, codepage is 1252, embedded labels, delimiter is ',', msq);
QlikView Keep Functions

QlikView Keep Functions- QlikView Left Keep

QlikView Keep Functions

QlikView Keep Functions- QlikView Left Keep

c. QlikView Right Keep

The Right keep, on the contrary, fetches all the values from the right table (Product List) and the common values from the left table.

Name:
LOAD Product_Id,
     Product_Type,
     Product_name
FROM
[C:\Users\HP\Desktop\Dataflair\productname.csv]
(txt, codepage is 1252, embedded labels, delimiter is ',', msq);

RIGHT KEEP(Name)
LOAD Product_Id,
     Product_Type,
FROM
[C:\Users\HP\Desktop\Dataflair\Product List.csv]
(txt, codepage is 1252, embedded labels, delimiter is ',', msq);
QlikView Keep Functions

QlikView Keep Functions- QlikView Right Keep

Do you know how to Generate Data in QlikView?

QlikView Keep Functions

QlikView Keep Functions- QlikView Right Keep

So, this was all about QlikView Keep Function. Hope you like our explanation.

4. Conclusion

Hence, QlikView Keep function is beneficial as it provides the original table as well as the combined in the memory for users to create table as per their convenience. It eliminates data redundancy as well. Still, have a confusion, share your query with us!

Related Topic – QlikView Dimensions and Measures

For reference 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.