Combining tables using Joins and Keep

Suparna Das
2 min readMay 28, 2023

--

Combining tables using joins and keep in Qlik is a technique used to merge or concatenate data from multiple tables based on common fields or keys. Qlik is a business intelligence and data visualization platform that allows users to perform data analysis and create interactive visualizations.

In Qlik, you can combine tables using different types of joins, such as inner join, left join, right join, and full outer join. Joins help you bring together data from different tables based on matching values in specified fields.

Here’s a brief explanation of the common types of joins in Qlik:

  1. Inner Join: An inner join returns only the records that have matching values in both tables. It combines the rows from the tables based on the common field(s) and includes only the matching records.
  2. Left Join: A left join returns all records from the left (or first) table and the matching records from the right (or second) table. If there is no match in the right table, null values are included for the right table’s fields.
  3. Right Join: A right join returns all records from the right (or second) table and the matching records from the left (or first) table. If there is no match in the left table, null values are included for the left table’s fields.
  4. Full Outer Join: A full outer join returns all records from both tables, including both matching and non-matching records. If there is no match, null values are included for the respective table’s fields.

In Qlik, the ‘Keep’ keyword is used to specify which fields you want to keep or include in the resulting table. You can use ‘Keep’ in conjunction with joins to control which fields from the joined tables should be included in the final result.

Here’s an example of combining tables using an inner join and keep in Qlik:

Table1:

LOAD ID, Name, Age

FROM data1.csv;

Table2:

LOAD ID, Department

FROM data2.csv;

JoinedTable:

JOIN (Table1)

LOAD ID, Name, Age, Department RESIDENT Table2;

FinalTable:

KEEP(ID, Name, Age, Department)

LOAD *

RESIDENT JoinedTable;

In this example, we load data from two separate CSV files into ‘Table1’ and ‘Table2’. Then, we perform an inner join between ‘Table1’ and ‘Table2’ based on the common field ‘ID’. The resulting joined table is stored in ‘JoinedTable’. Finally, we use the ‘KEEP’ keyword to select and keep only specific fields from ‘JoinedTable’ to create the ‘FinalTable’ with the desired fields.

Note that the actual table and field names, as well as the data source (e.g., CSV files), may vary depending on your specific use case in Qlik.

--

--