QlikView - Generating Data



Many times, we need some data to be generated programmatically by the software being used, which is not coming from a source. For example, 100 random numbers or just the dates of 23rd week of a year. A data analyst may need such data to be created to perform some analysis on the data that does not contain these values as it arrived. QlikView provides a function called Autogenerate, which can be used for such requirement.

Data Requirement

Consider a scenario where we need to find only the dates, which are a Thursday or a Sunday. We need to find it for the range starting today until the end of the year. We create the following script, which will achieve this.

generate_data_load_script

Explanation

We declare two variables to capture the first day of the current month and end of the year. Next we apply various functions and a filter condition to generate the required values. The recno() function creates one record for each of these dates. We add Autogenerate function giving the variables as the range.

Generated data

On loading the above script to QlikView's memory and creating a Table Box using the menu Layout → New Sheet Objects → Table Box, we get the data created as shown below.

generate_data_calendar
Advertisements