bing
Flat 10% & upto 50% off + Free additional Courses. Hurry up!

Creating a Document

 

1. LOADING DATA INTO QLIKVIEW

 A QlikView document is created by retrieving data from a source, e.g. from a relational database or from text files containing data tables. This retrieval is done by writing and executing a script, in which the database, the tables and the fields to be retrieved are specified. The script can be generated automatically with the tools included in QlikView.

 

q42

 

 

  • Looking at a delimited text file

You’ll start by looking at a csv file in a text editor:

  1. Start a text editor, e.g. Notepad (found in the Windows Accessories group).
  2. Open the file csv from the ..\TutorialFiles\Application\Examples directory (choose All Files in the Files of Type box).
  3. Close the text editor.
  4. Comma separated value files and text files with other delimiters, such as tab or semicolon, can often be imported to, and exported from, spreadsheet programs.

Master the best tool for self-service analytics with the Intellipaat Qlik Sense training course.

q43

 

 

  • Loading the text file
  1. Start QlikView (see the Basics chapter if you have forgotten).
  2. Choose New from the File menu or from the toolbar. The next thing to do is to create a script that specifies the files to load:
  3. Choose Edit Script from the File menu or from the toolbar. Choose Table Files on the Data tab. This opens the Open Local Files dialog box, in which you can browse for the file you wish to load. Make sure that the control Files of Type is set to Table Files. Find the file csv (the one you opened in the text editor before), select it and choose Open. The file is now opened in the file wizard, which interprets the contents of the file and helps you to load the data into the script in a correct way. Since the program has made a correct interpretation of the file, you can click Finish.

A script similar to the one below has been generated in the Edit Script dialog:

Load Country,

Capital,

[Area(km.sq)],

[Population(mio)],

[Pop. Growth],

Currency,

Inflation,

[Official name of Country]

from c:\qlikview\tutorialfiles\

application\examples\country1.csv

(ansi, txt, delimiter is ',', embedded labels);

 

  1. Study the script. Note that the words set, load and from are highlighted. This Choose Run. The data is now loaded into QlikView, and a dialog box in which it is possible to select the fields to be displayed is opened. Select the fields Area (km.sq.), Capital, Currency and Population(mio) by CTRL-clicking their names, then choose Add> to include them in the list of displayed fields. Another possibility is to double-click the field names. This will immediately put them in the list of displayed fields. The field names starting by “$” are system fields (they are only shown if the check box Show System Fields is selected).
  2. Choose OK to close the dialog. All the fields in the column Displayed Fields will be displayed as list boxes on the active QlikView sheet.
  3. Click on a capital, and you will find e.g. the currency used in that city.

Clear your selections.

 

2. ASSOCIATING DATA FROM MANY TABLES

 

  • Associations

 If you have two tables listing different things, e.g. if you have one list of customers and one list of invoices, and the two tables have a field (column) in common, e.g. the customer number, this usually means that there is a relationship between the two tables.

If such a relationship exists, associations are made between the fields that are common to the tables: QlikView assumes that the two fields are one and the same thing, and the two fields are treated as one. Such a field connecting two or more tables is called a key

There are two basic rules for associations:

  1. For two fields to be associated, they need to have the exact same name (case sensitive). Thus, e.g., Name and name are not the same and are not associated.
  2. If a certain field has the exact same value in several different input tables, QlikView will treat it as one value and also assume that the records (rows) containing the value should be associated. For two field values to be associated, they either need to
    • have exactly the same spelling (case sensitive), or
    • have exactly the same numeric value

A detailed understanding of QlikView is available in this blog post for your perusal !

  • Loading and associating a second table

The new table is found in an Excel file, but you can load it in the same easy way as a text file.

  1. Choose Edit Script from the File menu or from the toolbar.
  2. Place the cursor at the end of the script.
  3. Choose Table files.
  4. Select xls from the …Tutorial\Application\Examples directory and choose Open.
  5. Note that Excel is set as type this time, and that the Table box contains the name of the worksheet. This Excel document contains only one worksheet; if there had been several sheets or named tables, the Table box would have given you the possibility of choosing from which one of them data should be retrieved. Click Finish. Your script will now look similar to the one below (to improve clarity, we will from now on show relative paths, since the directory will stay the same):
 Load Country,

Capital,

[Area(km.sq)],

[Population(mio)],

[Pop. Growth],

Currency,

Inflation,

[Official name of Country]

from country1.csv (ansi, txt, delimiter is

',',embedded labels);

Load [Customer ID],

Customer,

Address,

City,

Zip,

Country

from customer.xls (ansi, biff, embedded labels, table

is [Customer$]);
  1. Choose Run.
  2. The dialog in which you choose the fields to display now appears. All fields, except the field Country from the file xls have been added to the column of available fields. The field Country is shown in the list of displayed fields. The field Country has been associated with the previously loaded fields with the same fieldname.
  3. Add the field Customer to the column of displayed fields.
  4. Choose OK.
  5. Save your document.
  6. Click Alma-Ata, the capital of Kazakstan, and note that the fictive company has two customers in Kazakstan.
  7. Clear your selections.

 

  • Renaming fields

 The directory contains additional files (tables) that are relevant to your document. Suppose you want to associate the file Transact.csv, a file containing information about transactions, sales, etc. concerning the customers in the document:

  1. Choose Edit Script from the File menu or from the toolbar.
  2. Place the cursor at the end of the script.
  3. Choose Table Files.
  4. Select csv and choose Open. This opens the file wizard
  5. Make sure that Delimited is set as type, Comma as delimiter and that the check box Embedded Labels is selected.
  6. The file wizard provides excellent possibilities for renaming fields. Simply click in the table header of ID Customer, then type the new name, Customer ID. Make sure not to forget the space between the words: any misspelling prevents QlikView from interpreting the fields as being one and the same.
  7. Press ENTER. The name of the field has been changed.
  8. Click Finish.

 

The automatically generated script looks similar to the one below:

 Load Country,

Capital,

[Area(km.sq)],

[Population(mio)],

[Pop. Growth],

Currency,

Inflation,

[Official name of Country]

from country1.csv (ansi, txt, delimiter is ',',

embedded labels);

Load [Customer ID],

Customer,

Address,

City,

Zip,

Country,

from customer.xls (ansi, biff, embedded labels, table

is [Customer$]);

Load [Transaction ID],

Year,

Month,

Day,

[Salesman ID],

[Product ID],

[SerialNo],

[ID Customer] as [Customer ID],

[List Price],

Sales,

[Gross Margin]

from transact.csv (ansi, txt, delimiter is ',',

embedded labels);

Note the line [ID Customer] as [Customer ID]: it has appeared as a result of the change you made in the file wizard, and means that the field ID Customer will be loaded into QlikView with the name Customer ID (thus assuring the necessary association).

  1. Choose Run.
  2. The Fields page of the Sheet Properties dialog appears. Add a field from the file csv to the column of displayed fields, e.g. Sales.
  3. Click OK.
  4. Save your document.
  5. Select Finland in the list box Country. The program immediately provides the geographical data stored in the country tables – but also displays the names of the customers residing in Finland, as well as the sales values related to them.
  6. Clear your selections.

 

3. CONCATENATING TABLES

However, instead of being associated, tables can also be merged. If two input tables are lists of the same thing, but contain different values, e.g. if one is a list of countries in Europe and the other one a list of countries in North and South America, the second table can be seen as a continuation of the first. The tables should then be concatenated.

 

  • Automatic concatenation

 If two tables that have exactly the same set of fields are entered, QlikView automatically treats the second table as a continuation of the first. This is called concatenation of tables. Any number of tables can be concatenated into one table.

Your QlikView document retrieved data from a file with a limited number of countries. The Tutorial\Application\Examples directory contains a second file listing countries, whose field names correspond exactly to those of the already loaded Country1.csv. When you load the second file, the two tables will be automatically concatenated.

  1. Choose Edit Script from the File menu or from the toolbar.
  2. Position the cursor after the load statement loading the file csv (all statements end with a
  3. semicolon) and press ENTER to get an empty row. The order of the load statements is arbitrary, but you get a better overview of your script by keeping the country files together.
  4. Click Table Files.
  5. Select csv, then choose Open. This opens the file wizard
  6. Make sure that Delimited is set as type, Comma as delimiter and that the check box Embedded Labels is selected.
  7. You don’t need to rename any fields this time, so click Finish. You should now have a script similar to the following:
Load Country,

Capital,

[Area(km.sq)],

[Population(mio)],

[Pop. Growth],

Currency,

Inflation,

[Official name of Country]

from country1.csv (ansi, txt, delimiter is ',',

embedded labels);

Load Country,

Capital,

[Area(km.sq)],

[Population(mio)],

[Pop. Growth],

Currency,

Inflation,

[Official name of Country]

from country2.csv (ansi, txt, delimiter is ',',

embedded labels);

Load [Customer ID],

Customer,

Address,

City,

Zip,

Country,

from customer.xls (ansi, biff, embedded labels,

table is [Customer$]);

Load [Transaction ID],

Year,

Month,

Day,

[Salesman ID],

[Product ID],

[Serial No],

[ID Customer] as [Customer ID],

[List Price],

Sales,

Gross Margin

from transact.csv (ansi, txt, delimiter is ',',

embedded labels);

 

  1. Choose Run. The Fields page in the Sheet Properties dialog box is opened. The fields you selected last time are already in the column of displayed fields. No new fields have appeared in the list of available fields, since the field values of csv have been added to the corresponding fields of Country1.csv.
  2. Choose OK to close the dialog.
  3. Save your document.

 

  • Forced concatenation

 Sometimes you want to concatenate tables also when they have different sets of fields. QlikView will then not automatically concatenate the two tables: you need to use the concatenate statement, which concatenates a table with the last created logical table.

The values of the missing fields in the concatenated table will be NULL, i.e. Qlik-

View will treat these fields as having no value.

Do the following:

  1. Choose Edit Script from the File menu or from the toolbar.
  2. Position the cursor after the statement loading csv. This time the order of the statements is not arbitrary, since the concatenate statement forces concatenation with the last created logical table in the script.
  3. Choose Table Files.
  4. Select csv and choose Open. This opens the file wizard
  5. Make sure that the wizard has made a correct interpretation, then click Finish.

This generates a script similar to the one below:

Load Country,

Capital,

[Area(km.sq)],

[Population(mio)],

[Pop. Growth],

Currency,

Inflation,

[Official name of Country]

from country1.csv (ansi, txt, delimiter is ',',

embedded labels);

Load Country,

Capital,

[Area(km.sq)],

[Population(mio)],

[Pop. Growth],

Currency,

Inflation,

[Official name of Country]

from country2.csv (ansi, txt, delimiter is ',',

embedded labels);

Load Country,

[Official name of Country],

[Area(km.sq)]

from country3.csv (ansi, txt, delimiter is ',',

embedded labels);

Load [Customer ID],

Customer,

Address,

City,

Zip,

Country,

from customer.xls (ansi, biff, embedded labels, table

is [Customer$]);

Load [Transaction ID],

Year,

Month,

Day,

[Salesman ID],

[Product ID],

[Serial No],

[ID Customer] as [Customer ID],

[List Price],

Sales,

Gross Margin

from transact.csv (ansi, txt, delimiter is ',',

embedded labels);

 

Position the cursor in front of the load statement that loads Country3.csv and type Concatenate. If the spelling is correct, the word concatenate will turn blue just like load and from etc., since it is also a keyword. Make sure there is a space between the two words:

Concatenate Load Country,

Official name of Country],

[Area(km.sq)],

from country3.csv (ansi, txt, delimiter is ‘,’,

embedded labels);

  1. Choose Run.
  2. Click the OK
  3. Select the country Seychelles.
  4. Clear your selections.

To get a clear picture of the contents of the concatenated table, create a table box containing the fields of the country files, i.e. Country, Capital, Area (km.sq), Population(mio), Pop.Growth, Currency, Inflation, Official name of Country. Use the scroll bar to browse through the data of your table box. You’ll note

that some of the rows are not complete, but contain a ’-’ instead of a value. This is the case for all the countries from the third country file, containing only a subset of the fields: the values of the missing fields are treated as NULL.

 

  • Using the Table Viewer
  1. Choose Table Viewer from the File
  2. Click on the header of the table Country1. All tables directly associated with this table (only one actually) will be highlighted.
  3. Click on the field Customer ID in one of the tables where it appears. Notice that the field name will be highlighted in all tables where it appears.
  4. Close the Table Viewer by clicking OK.

 

Read these top trending QlikView Interview Q’s that helps you grab high-paying jobs !

 

4. LINKING EXTERNAL INFORMATION TO A DOCUMENT

 The links are defined in information tables which must be loaded in a special way. In this lesson you’ll link flags to specific values in the Country list box.

 

  • Looking at an info file
  1. Open a text editor, e.g. Notepad, and choose Open from the File
  2. In the box Files of type, select All files.
  3. Open the file Flagsoecd.csv in the …\Tutorial\Application\Examples directory.
  4. Close the editor.

 

q44

 

 

  • Loading the info file

 The next step is to load the info file into QlikView.

  1. Choose Edit Script, and click Table Files.
  2. Select the file csv and click Open. This opens the file wizard.
  3. Like for the files already loaded, Delimited is set as type, Comma as delimiter.
  4. Embedded Labels is selected as label.
  5. Click Finish.
  6. Change the script by manually adding the word info before the load
  7. The word info being a keyword in the script, it will turn blue. The script should look similar to the following:
...

Load [Transaction ID],

Year,

Month,

Day,

[Salesman ID],

[Product ID],

[Serial No],

[ID Customer] as [Customer ID],

[List Price],

Sales,

Gross Margin

from transact.csv (ansi, txt, delimiter is ',',

embedded labels);

Info Load Country,

I

from flagsoecd.csv (ansi, txt, delimiter is ',', embedded labels);
  1. Choose Run.
  2. The Fields page is opened. No new fields have been added. Click OK.
  3. Save your application.

 

  • Viewing the linked information
  1. Select Germany from the list of countries.
  2. A small info symbol appears in the upper right-hand corner of the list box. Click it.
  3. Close the window
  4. Select France from the list of countries.
  5. Click the info symbol to make the specified picture appear
  6. Close the flag and clear all selections.

 

q45

 

 

  • Embedding external info

If you want to be able to send a QlikView document to other people without worrying about sending the picture files as well, there is an option to embed the info in the QlikView file.

  1. Choose Edit Script
  2. Find the statement which starts by info load.
  3. Precede that statement with the word bundle, so that it now starts bundle info load.
  4. Run the script.

 

5. LOADING ADDITIONAL FILES

 

  • Loading a tab separated file without labels

The loading procedure is similar to the one you’ve encountered in the previous lessons:

  1. Go to the Sales
  2. Choose Edit Script from the File menu or from the toolbar.
  3. Position the cursor at the end of the script.
  4. Click Table Files.
  5. Select tab, then choose Open. This opens the Table wizard (see above).
  6. Delimited is still set as type, but this time Tab is selected as delimiter. Furthermore, Labels should be set to None because the first row contains ordinary field values, not field names. Change Labels to None in the drop-down list if does not already have this setting.
  7. Click in the header of the first column where it says @1. Type Market and press ENTER. Click in the header of the second column where it says @2. Type Country and press ENTER
  8. Click Finish. Your script now looks similar to the one below:
...

Info Load Country,

I

from infofile.csv (ansi, txt, delimiter is ',',

embedded labels);

Load @1 as Market,

@2 as Country

from markets.tab (ansi, txt, delimiter is '\t', no

labels);
  1. Click Run to execute the script.
  2. Move the new field Market to the column of displayed fields, then click OK.

 

  • Loading a file via ODBC
  1. Open the Edit Script
  2. Instead of clicking Table Files, you must now click the Connect button to establish a connection with the data source.
  3. The Data Link Properties dialog opens. Make sure that the OLE DB Provider for ODBC Drivers is selected, then click Next to get to the Connection Since you are working with a generic data source not yet defined, select the option Use connection string, then click the Build button.
  4. Go to the tab Machine Data Source.
  5. Select MS Access Database, then click OK.
  6. From the Login dialog that opens, click the .. button.
  7. Browse for the file. Once you find the correct location, the salesman file should be the only one available in the left list. Select it, then click OK to close the dialog.
  8. Click OK to close the remaining dialogs.
  9. Click the Select

 

q46

 

 

By default, a star is selected in the SELECT group. The star is equivalent to all fields. You want to load all fields, but for consistency reasons you’ll select them to make their names appear in the script:

  1. Click on the field Salesman ID, then press the SHIFT key and hold it down while clicking the last field name. Verify that all the fields are selected by studying the preview.
  2. Click OK. Your script should now look similar to the following:
...

Load @1 as Market,

@2 as Country

from markets.tab (ansi, txt, delimiter is '\t', no

labels);

CONNECT TO 'MS Access Database;

DBQ=c:\QlikView\TutorialFiles\Application\

Examples\SALESMAN.mdb;';

SQL SELECT `Salesman ID`, Salesman, `Distributor ID`

FROM SALESMAN;

The salesman table is associated with the existing data via the field Salesman ID, which it has in common with Transact.csv.

  1. Click Run.
  2. Add the new field Salesman to the Sales sheet and study the relations by making a few selections.
  3. Clear your selections.

 

"0 Responses on Creating a Document"

Training in Cities

Bangalore, Hyderabad, Chennai, Delhi, Kolkata, UK, London, Chicago, San Francisco, Dallas, Washington, New York, Orlando, Boston

100% Secure Payments. All major credit & debit cards accepted Or Pay by Paypal.

top

Sales Offer

  • To avail this offer, enroll before 10th December 2016.
  • This offer cannot be combined with any other offer.
  • This offer is valid on selected courses only.
  • Please use coupon codes mentioned below to avail the offer
offer-june

Sign Up or Login to view the Free Creating a Document.