Using VBS functions in charts
999 times out of 1000, we can do everything that we need to do using the embedded QlikView functions. There is just that one in a thousand awkward times, where there is a calculation that is just not calculable by combining those functions.
In this recipe we will examine the
Days360
function. This function calculates the number of days between two dates based on a 360 day year, that is, 30 days per whole month. There is a slightly different calculation between Europe and the U.S., so we will take that into account.
Getting ready
We don't need a special QlikView document here. Any document will do.
How to do it…
These steps show you how to use a VBS function in a chart:
From the Tools menu, select Edit Module….
Enter the following code:
Option Explicit Function Days360(StartDate, EndDate, European) Dim Days1, Days2 Days1 = Day(EndDate) Days2 = Day(StartDate) If European and Days1 = 31 Then Days1 = 30 If European and Days2 = 31 Then Days2 = 30 Days360...