0% found this document useful (0 votes)
169 views4 pages

Understanding Join Keep Concat

The document discusses different ways to join, keep, and concatenate tables in QlikView: - JOIN combines rows where the key values match and allows retaining unmatched rows using options like LEFT, RIGHT, and OUTER. - KEEP is similar to JOIN but stores the tables separately rather than joining them, reducing memory usage. Options like LEFT KEEP only keep matching rows from one table. - CONCATENATE appends all rows from one table to another without merging, essentially stacking the tables one after another.

Uploaded by

Nag Dhall
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
169 views4 pages

Understanding Join Keep Concat

The document discusses different ways to join, keep, and concatenate tables in QlikView: - JOIN combines rows where the key values match and allows retaining unmatched rows using options like LEFT, RIGHT, and OUTER. - KEEP is similar to JOIN but stores the tables separately rather than joining them, reducing memory usage. Options like LEFT KEEP only keep matching rows from one table. - CONCATENATE appends all rows from one table to another without merging, essentially stacking the tables one after another.

Uploaded by

Nag Dhall
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Understanding Join, Keep and Concatenate

Common scenarios are ...

concatenate: two or more tables contain the same fields and you want to bring them together into a single table left join: two or more tables have a single common key and you want to bring additional fields from one or more child tables into a master table association (the QlikView default): this is essentially a many-to-many join and very powerful; you will use this option 90% of the time mapping load and applymap(): similar to a left join but often more efficient in terms of CPU ------------------------------Joins purely depends on the requirement, there is no restriction/best one to use. Inner join - If we want to load only the matching records in both the tables then use Inner Join. Left join - If we want to load all records in first table and matching records in second table, the unmatched records in second table will be null, in this scenario Left Join is used. Right join - If we want to load all records in second table and matching records in first table, the unmatched records in first table will be null, in this scenario Right Join is used..

Posted by John Denard in QVScriptor on Nov 11, 2011 5:42:06 AM

Hi, We have completed the QlikView Joins method in order to cover the all the 3 joins methods of QlikView.

The QlikView script functions JOIN, KEEP and CONCATENATE can sometimes be used to solve the same problem, but there are important differences that should be understood. Examine the sample tables below. Note that they share one common field name, "Key". Also note that Table1 has a Key value "3" that is not present in Table2 and that Table2 has a key 4 that is not present in Table1.

Table1 Key 1 2 3 A A1 A2 A3

Table2 Key 1 2 C C1 C2

C4

Type of Joins:
JOIN will combine rows where the Key value matches. The keyword OUTER will also retain rows that do not match rows in the other table. The keyword LEFT will retain rows from the left table but only matching rows from the right table The keyword RIGHT will retain rows from the right table but only matching rows from the left table The keyword INNER will retain rows matching the left table and right table

Joins
Here's what the merged table will look like after the different join methods. Note that QlikView merge the two tables after a Join.

Note: The explicit join keyword (= Outer Join) in QlikView script language performs a full join of the two tables. The result is one table. In many cases such joins will result in very large tables. One of the main features of QlikView is its ability to make associations between tables instead of joining them, which greatly reduces memory usage, increases processing speed and offers enormous flexibility. Explicit joins should therefore be generally avoided in QlikView scripts. The keep functionality was designed to reduce the number of cases where you need to use explicit joins OUTER JOIN (Table1) Key 1 2 3 4 A A1 A2 A3 C C1 C2 C4 LEFT JOIN (Table1) Key 1 2 3 A A1 A2 A3 C C1 C2 4 C4 RIGHT JOIN (Table1) Key 1 2 A A1 A2 C C1 C2 INNER JOIN (Table1) Key 1 2 A A1 A2 C C1 C2

Keep
The keep prefix between two load or select statements has the effect of reducing one or both of the two tables before they are stored in QlikView, based on the intersection of table data. The keep keyword must always be preceded by one of the prefixes inner,left or right. The selection of records from the tables is made in the same way as in a corresponding join. However, the two tables are not joined and will be stored in QlikView as two separately named tables. LEFT KEEP Table1 Key 1 2 3 A A1 A2 A3 Table2 Key 1 2 3 C C1 C2 4 4 C4 RIGHT KEEP Table1 Key 1 2 A A1 A2 Table2 Key 1 2 C C1 C2 INNER KEEP Table1 Key 1 2 A A1 A2 Table2 Key 1 2 C C1 C2

Concatenate
Now let's look at Concatenate. Concatenate appends the rows of one table to another. Concatenate never merges any rows. The number of rows in a concatenated table is always the sum of the rows from the two input tables. Here's what our sample data will look like after Concatenate.

CONCATENATE (Table1) LOAD * RESIDENT Table2;

Key 1 1 2 2 3 4

A A1

C1 A2 C2 A3 C4

Rows with like Key values are not merged together. The rows from Table2 are simply appended to Table1. Because the tables have different fields, rows will have null values for the fields from the "other" table.

QsGen Team

You might also like