Creating flags in the script
Creating flags in the script is something that experienced QlikView developers will do almost without thinking. If they need to improve the performance of an expression, or just make an expression easier to write, they will probably create a flag field in the script. By moving linear calculations to the script and creating numeric fields, it means that the frontend performance will be vastly improved.
Often, these will be created by simple If
statements, but they can also be more complex.
In this recipe, we will look at creating a flag to help us calculate the end of period positions.
Getting ready
Load the following script:
Load Date(TempDate) As Date, WeekDay(TempDate) as WeekDay, Year(TempDate) As Year, Month(TempDate) As Month, Date(MonthStart(TempDate), 'YYYY-MM') As YearMonth, WeekYear(TempDate) & '-' & Num(Week(TempDate), '00') As YearWeek, Floor(5000 * Rand()) As StockVolume; Load RecNo()-1+Floor(MakeDate(2012)) As TempDate AutoGenerate...