Discussion Board for collaboration related to QlikView App Development.
Hey all,
For a flag I'm attempting to generate, I need to create a function that will read in the current month of a project (in my calendar) and return the next month. I've been having trouble finding good documentation defining the relationship between module (User Defined Function) and the script. Here is the current function I've developed:
function NextMonth(MonthParam)
dim NewMonth
IF MonthParam = "Oct" then set vNewMonth = "Nov"
IF MonthParam = "Nov" then set vNewMonth = "Dec"
IF MonthParam = "Dec" then set vNewMonth = "Jan"
IF MonthParam = "Jan" then set vNewMonth = "Feb"
IF MonthParam = "Feb" then set vNewMonth = "Mar"
IF MonthParam = "Mar" then set vNewMonth = "Apr"
IF MonthParam = "Apr" then set vNewMonth = "May"
IF MonthParam = "May" then set vNewMonth = "Jun"
IF MonthParam = "Jun" then set vNewMonth = "Jul"
IF MonthParam = "Jul" then set vNewMonth = "Aug"
IF MonthParam = "Aug" then set vNewMonth = "Sep"
IF MonthParam = "Sep" then set vNewMonth = "Oct"
end function
A few of the things I'm curious about are:
- Do you need to define a variable type for an input parameter
- Can you have a function return a value, or must you set a new variable in the function
- Can you input a string? How do the quotes work, a single quote is a comment and leaving it blank seems wrong
- How do you use a variable you set in a function in your script?
I would create a variable using this (I usually dont use macros or Vb script)
Date(Addmonths(MakeDate(1900,'$1'),1),'MMM')
and use like this
=$(vNextMonth(02)) // returns 'mar'
I would create a variable using this (I usually dont use macros or Vb script)
Date(Addmonths(MakeDate(1900,'$1'),1),'MMM')
and use like this
=$(vNextMonth(02)) // returns 'mar'
Thanks! works like a charm