Script example
In this example, the data is first loaded without the AutoNumber statement. The AutoNumber statement is then added to show the effect.
Data used in the example
Load the following data as an inline load in the data load editor to create the script example below. Leave the AutoNumber statement commented out for now.
RegionSales:
LOAD *,
Region &'|'& Year &'|'& Month as KeyToOtherTable
INLINE
[ Region, Year, Month, Sales
North, 2014, May, 245
North, 2014, May, 347
North, 2014, June, 127
South, 2014, June, 645
South, 2013, May, 367
South, 2013, May, 221
];
Budget:
LOAD Budget,
Region &'|'& Year &'|'& Month as KeyToOtherTable
INLINE
[Region, Year, Month, Budget
North, 2014, May, 200
North, 2014, May, 350
North, 2014, June, 150
South, 2014, June, 500
South, 2013, May, 300
South, 2013, May, 200
];
//AutoNumber KeyToOtherTable;
For more information about using inline loads, see Using inline loads to load data.
Create visualizations
Create two table visualizations in a Qlik Sense sheet. Add KeyToOtherTable, Region, Year, Month, and Sales as dimensions to the first table. Add KeyToOtherTable, Region, Year, Month, and Budget as dimensions to the second table.
Result
RegionSales table
| KeyToOtherTable |
Region |
Year |
Month |
Sales |
| North|2014|June |
North |
2014 |
June |
127 |
| North|2014|May |
North |
2014 |
May |
245 |
| North|2014|May |
North |
2014 |
May |
347 |
| South|2013|May |
South |
2013 |
May |
221 |
| South|2013|May |
South |
2013 |
May |
367 |
| South|2014|June |
South |
2014 |
June |
645 |
Budget table
| KeyToOtherTable |
Region |
Year |
Month |
Budget |
| North|2014|June |
North |
2014 |
June |
150 |
| North|2014|May |
North |
2014 |
May |
200 |
| North|2014|May |
North |
2014 |
May |
350 |
| South|2013|May |
South |
2013 |
May |
200 |
| South|2013|May |
South |
2013 |
May |
300 |
| South|2014|June |
South |
2014 |
June |
500 |
Explanation
The example shows a composite field KeyToOtherTable that links the two tables. AutoNumber is not used. Note the length of the KeyToOtherTable values.
Add AutoNumber statement
Uncomment the AutoNumber statement in the load script:
AutoNumber KeyToOtherTable;
Result
RegionSales table
| KeyToOtherTable |
Region |
Year |
Month |
Sales |
| 1 |
North |
2014 |
June |
127 |
| 1 |
North |
2014 |
May |
245 |
| 2 |
North |
2014 |
May |
347 |
| 3 |
South |
2013 |
May |
221 |
| 4 |
South |
2013 |
May |
367 |
| 4 |
South |
2014 |
June |
645 |
Budget table
| KeyToOtherTable |
Region |
Year |
Month |
Budget |
| 1 |
North |
2014 |
June |
150 |
| 1 |
North |
2014 |
May |
200 |
| 2 |
North |
2014 |
May |
350 |
| 3 |
South |
2013 |
May |
200 |
| 4 |
South |
2013 |
May |
300 |
| 4 |
South |
2014 |
June |
500 |
Explanation
The KeyToOtherTable field values have been replaced with unique integer values and, as a result, the length of the field values has been reduced, thus conserving memory. The key fields in both tables are affected by AutoNumber and the tables remain linked. The example is brief for demonstration purposes, but would be meaningful with a table containing a large number of rows.