QlikView Keep Functions
In QlikView, “Keep” functions are used to create a set of records based on specified criteria. There are several types of Keep functions in QlikView, including:
- Keep: This function is used to create a set of records that includes only the specified field values.
- Keep Dual: This function is used to create a set of records that includes only the specified field values and their corresponding labels.
- Keep Only: This function is used to create a set of records that includes only the specified field values and removes all other field values from the data set.
- Keep Excluded: This function is used to create a set of records that includes all field values except the specified field values.
- Keep Different: This function is used to create a set of records that includes only the field values that are different from the specified field value.
Keep functions are often used in conjunction with other functions, such as the “Count” function, to perform statistical analysis or create summary reports. They can also be used to filter data or create subsets of data for further analysis.
To use a Keep function in QlikView, you can specify the field and the values you want to include or exclude in the function. For example, to create a set of records that includes only the field values “A” and “B,” you could use the following Keep function:
Keep(Field1, ‘A’, ‘B’)
This function would create a set of records that includes only the records where Field1 has a value of “A” or “B.”
In QlikView, the “KEEP” function is used to select specific fields or columns from a table and create a new table with only those fields. The “KEEP” function is used in combination with the “LOAD” statement and can be used to filter data before it is loaded into the QlikView document.
For example:
vbnetCopy code
LOAD
customer_id,
first_name,
last_name
FROM customers.csv (txt, utf8, embedded labels, delimiter is ',')
KEEP customer_id;
This will load the customer_id, first_name, and last_name fields from the customers.csv file, but will only keep the customer_id field in the new table.
Another example:
vbnetCopy code
LOAD
customer_id,
first_name,
last_name
FROM customers.csv (txt, utf8, embedded labels, delimiter is ',')
KEEP customer_id, last_name;
This will load the customer_id, first_name, and last_name fields from the customers.csv file, but will only keep the customer_id and last_name fields in the new table.
You can also use the “KEEP” function with the “JOIN” function to select specific fields from multiple tables and join them together.
For example:
vbnetCopy code
LOAD customer_id, last_name
FROM customers.csv (txt, utf8, embedded labels, delimiter is ',')
KEEP customer_id, last_name
JOIN
LOAD order_id, customer_id
FROM orders.csv (txt, utf8, embedded labels, delimiter is ',')
KEEP order_id, customer_id;
This will load the customer_id and last_name fields from the customers.csv file, the order_id and customer_id fields from the orders.csv file and join them together based on the common field customer_id.
The “KEEP” function is useful for reducing the size of the data and making it more manageable, and also for selecting specific fields to be used in calculations or visualizations.