QlikView - Circular Reference


Circular Reference occurs when we can traverse from one table to another using two or more different paths. This means you can join Table1 with Table2 directly using a column or you can also first join Table1 with Table3 and then table3 with Table2. This can lead to incorrect result in the output formed by a data model, which loads all these three tables. QlikView prevents the load of such data into its memory once it recognizes a circular reference.

Input Data

Let us consider the following three CSV data files, which are used as input for further illustrations.

1,Outdoor Recreation,Italy,4579
3,Costumes & Accessories,South Korea,6521
5,Personal Care,Brazil,5124
6,Arts & Entertainment,China,1245
7,Hardware,South America,456
8,Home & Garden,Peru,241
10,Home & Garden,Singapore,5462
11,Office Supplies,Hungary,577

ProductID, Country
7,Sri Lanka

Load Script

We load the above input data using the script editor, which is invoked by pressing Control+E. Choose the option Table Files and browse for the Input file.


Data Load

After creating the above script, we load the data to QlikView's memory using the command Control+R. This is when we get the error prompt mentioning the presence of circular loop in the tables getting loaded.


Data Model

To find the exact cause of the above warning we can look at the data model by using the menu command for table viewer - Control+T. The following screen comes up, which clearly shows the circular reference. Here the join between RegionCountry and SalesRegion can be directly achieved using the field Region. It can also be achieved by first going to the table ProductCountry, using the field Country and then mapping ProdcutID with Salesregion.


Resolving Circular Reference

The above circular reference can be resolved by renaming some of the columns in the data sets so that QlikView does not form an association between the tables automatically using the column names. For this, we will rename country column in RegionCountry to SalesCountry. In the data set ProdcuCountry, we rename the Country column to ProductCountry.


Rectified Data Model

The Rectified data model after renaming the column above can be seen using the command Control+T. Now we can see that the relationship between the tables does not form a loop.


Pressing Control+R to reload the data does not give us the warning anymore and we can use this data to create reports.