Professional Documents
Culture Documents
Exercise - INSTRUCTIONS
Using the files in the Example Download section on the right and the instructions Example Download
below, you can practice combining tables in QlikView using the MAPPING prefix.
The example files provided for this
exercise contain information about
combining tables using mapping.
©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.
Mapping Bands’ City of Origin
Close Edit Script dialog and view sheet, Bands and Origins
The reason for this is that, in the Bands table, Queen has no OriginID value. This can be seen by
previewing the Bands table in the Table Viewer.
It can also be seen in the table box on the Bands and Origins tab in sheet view.
Note: NULLs don’t appear in list boxes.
©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
Map OriginName to the Bands table
We will combine the small Origins table with the Bands table, with the immediate benefit of being able to
create a default OriginName that will appear in list boxes for any band where their city of origin is missing
from our database.
Open the Edit Script dialog and add a new tab, name it Mapping, and position it to immediately
follow Main
In the Dimensions tab, cut the whole script block for the Origins table, including the comment,
LOAD and SQL SELECT statements to the clipboard
Paste the contents of the clipboard into the Mapping tab. Consider how you would change the
following script in order to turn this into a mapping table.
Ensure table has two fields only and the first field is the lookup field
©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 3
Use ApplyMap()
In the Dimensions tab, use the ApplyMap() function in the Bands table LOAD statement,
remembering to paste the table name from the clipboard to ensure it is spelled correctly The
script should look like this:
Click Reload
The scrollbar on the Bands table indicates that it has gained a new field.
Preview the Bands table. Does the OriginID field serve us in any useful way?
(Answer: No. We can drop it and not lose any information or table association.
Optional: Return to the Edit Script Dialog and add the following below the Bands LOAD block to
drop the field, OriginID:
Click Reload
Return to the Bands and Origins sheet. Have the OriginName list box contents changed?
(Answer: There is a new item, “Unknown City”)
©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 4
Mapping Musicians’ Primary Instrument
Open the Musicians and Instruments sheet in sheet view. Clear all selections, if necessary.
If requirements state that we should display only one instrument for each musician, say their
primary instrument, MAPPING would be an ideal table-combining solution. In that case, one
technical requirement for the multi-instrumentalists would be that the mapping table loads the
instruments in a certain order. For our example, we’ll assume that the first instrument listed is that
musician’s primary instrument – for Pete Townsend, that would be a guitar.
Open Table Viewer and inspect the MusicianInstruments and Musicians tables.
Close the Table Viewer and open the Edit Script dialog.
In the Dimensions tab, cut the whole script block for the MusicianInstruments table, including the
comment, LOAD and SQL SELECT statements to the clipboard
Paste the contents of the clipboard into the Mapping tab below the Origins_map table, leaving a
few blank lines to aid readability.
Add the MAPPING prefix and modify the table name to indicate that it is a mapping table.
©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 5
Are the two fields in the correct order for a mapping table?
(Answer: No. Instrument appears first but it cannot be used as a lookup field.)
Reverse the order of the two fields in the load statement placing MusicianID first, so that it can be
used as the lookup field in the ApplyMap() function
Use ApplyMap()
In the Dimensions tab, use the ApplyMap() function in the Musicians table LOAD statement,
remembering to paste the table name from the clipboard to ensure it is spelled correctly
Click Reload
©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 6
What happened to the MusicianInstruments table?
(Answer: It was dropped at the end of script execution)
Return to the Musicians and Instruments sheet. How have the Musician and Instrument table box
contents changed?
(Answer: Only one instrument is now listed for each musician)
©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 7