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.
Let us consider the following three CSV data files, which are used as input for further illustrations.
SalesCountries: ProductID,ProductCategory,Country,SaleAmount 1,Outdoor Recreation,Italy,4579 2,Clothing,USA,4125 3,Costumes & Accessories,South Korea,6521 4,Athletics,Japan,4125 5,Personal Care,Brazil,5124 6,Arts & Entertainment,China,1245 7,Hardware,South America,456 8,Home & Garden,Peru,241 9,Food,India,1247 10,Home & Garden,Singapore,5462 11,Office Supplies,Hungary,577 ProductCountry: ProductID, Country 3,Brazil 3,China 2,Korea 1,USA 2,Singapore 7,Sri Lanka 1,Italy
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.
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.
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.
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.
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.