Está en la página 1de 2

Example Download

Learning module: Combining Tables - Joins


The example files provided for this
exercise, an Access .mdb format
Exercise - INSTRUCTIONS database, a .qvw file, and five .xlsx
files are zipped into an archive file
which is available for download from
Using the example download files on the right, you will practice joining tables, by the course site. Extract the files
joining the Origins (originating city) to the Bands table. from the zip archive and place them
in a convenient folder location on
your local hard drive.

Here are the files used in this


exercise assignment:
 Open the Combining tables – practice document
CombiningTables_practice.mdb
 In the script editor, comment out the OLEDB CONNECT32 statement on the Contains numerous tables
Measures tab centering on rock bands from the
sixties.
 Create a new OLE DB 32-bit connection, using the Microsoft Jet 4.0 provider, to
the CombiningTables_practice.mdb file Combining tables -
practice.qvw
 Reload the data then switch to the Table viewer and preview the tables to get a Pre-existing document with a data
feel for the existing data model and sheet objects based on
the .mdb above.
 We will join the Bands and Origins tables. Close the table viewer and script
BandAdditions.xlsx
editor, to return to the sheet view. On the Bands and Origins sheet, notice that we
MusicianAdditions_Beatles.xlsx
have three list boxes for the fields, BandName, OriginID, and OriginName
MusicianAdditions_Stones.xlsx
 In the OriginName list box, select New York and observe that none of our bands MusicianAdditions_TheWho.xlsx
MusicianAdditions_Hendrix.xlsx
are from that city
Excel files with additional band
 Clear the New York selection and select Queen. Notice that no city of origin has and musician data.
been recorded for this band
Place the .qvw and the source files
 Clear the BandName selection and re-open the Script editor. Locate the Origins
in the same folder on your hard
table load script on the Dimensions tab
drive, to make it easier to reference
 Comment out the Origins table label and, in its place, type, LEFT JOIN(Bands) within the script editor.

 Click Reload

 Close the execution progress, open the Table viewer and notice the Origins table is gone

 Preview the Bands table and notice that the Queen record remains but New York has been dropped from
this combined table - the scripted “LEFT JOIN (Bands)” placed the priority on retaining ALL records from the
Bands table, whether they had a matching OriginName or not. But any OriginName which had no
matching BandName was lost

 Return to the Bands and Origins sheet and verify these findings

 Re-open the Script editor, change the LEFT JOIN, to RIGHT JOIN and reload the data.
 Return to the Bands and Origins sheet. What does this view reveal about the right join? (Answer = All
cities of origin now appear, whether there is a matching band or not. However, any band that does
not have an OriginID (Queen) is dropped)

©2016 QlikTech International AB. All rights reserved. Qlik®, Qlik Sense®, QlikView®, QlikTech®, Qlik® Cloud, Qlik® DataMarket, Qlik® Analytics Platform and the Qlik logos
are trademarks of QlikTech International AB which have been registered in multiple countries. Other marks and logos mentioned herein are trademarks or registered trademarks
of their respective owners. Use of any and all of the foregoing is subject to the written approval of Qlik.
 Go back to the Script editor. change the RIGHT JOIN to an INNER JOIN and then reload the data again

 Return to the Bands and Origins sheet. How do you explain the results now? (Answer = The INNER JOIN
keeps only those rows where both tables have matching key values)
 Return to the Script editor, change the INNER JOIN to an OUTER JOIN, and then reload the data.

 Go back to the Bands and Origins sheet. You now see that all the data from both sides of the join are
present (Including Queen from the left table and New York from the right table)

In this exercise, you learned to use the join technique to combine tables. Care must always be taken when
determining which join qualification type to use (LEFT, RIGHT, INNER, OUTER). Depending upon the
requirements of the document, rows of data can be removed from the tables. Be sure to use the correct
type.

In addition, when a table contains numeric field data, ensure you are not inadvertently creating numerical
inconsistencies. Always check to see if the document requirements call for aggregate functions such as
SUM() on these fields on the front-end sheets.

©2016 QlikTech International AB. All rights reserved. Qlik®, Qlik Sense®, QlikView®, QlikTech®, Qlik® Cloud, Qlik® DataMarket, Qlik® Analytics Platform and the Qlik logos
are trademarks of QlikTech International AB which have been registered in multiple countries. Other marks and logos mentioned herein are trademarks or registered trademarks
of their respective owners. Use of any and all of the foregoing is subject to the written approval of Qlik.

Exercise instructions | page 2