Using Peek and Previous to calculate against loaded records
Previous
is an excellent function to be able to use in a QlikView script, because it allows us to look back at previous source records. Peek
allows us to look at records that have already been loaded into memory.
Both are very useful for making vertical calculations in the script. In this recipe, we will look at making period-on-period calculations.
Getting ready
Go to http://www.bls.gov/lau/, and look for the County Data table. Download the text file (currently at http://www.bls.gov/lau/laucntycur14.txt) to your PC.
Follow these steps to load the data:
Edit the script and click on the Table Files button:
Browse to the file that we downloaded previously. Set the File Type to Fixed Record. Set Record Size to Lines. Set Header Size also to Lines, and then increase the number of rows until all the header rows (including dashes) are removed:
Click on either side of each of the bars (|) in the text to create the correct columns for the data...