Example of Qualify and Unqualify statements
Let's look at an example of how to use the Qualify and Unqualify statements to resolve a synthetic key and a loop in a data model. Suppose you have three tables: Customers, Orders, and Products, that have the following fields:
Customers: CustomerID, Name, Country, Region
Orders: OrderID, CustomerID, ProductID, Quantity, Price
Products: ProductID, Name, Category, Cost
If you load these tables without any modification, QlikView will create a synthetic key based on the common field Name between Customers and Products, and a loop based on the multiple associations between Customers, Orders, and Products. To avoid these issues, you can use the Qualify and Unqualify statements as follows:
Qualify *; // qualify all fields in all tables
Unqualify CustomerID, ProductID; // unqualify the key fields
Load CustomerID, Name, Country, Region
Load OrderID, CustomerID, ProductID, Quantity, Price
Load ProductID, Name, Category, Cost
By using the Qualify and Unqualify statements, you will have a clean and simple data model that has only two associations: CustomerID between Customers and Orders, and ProductID between Orders and Products. No synthetic keys or loops will be created.