Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a field for year_month and need to make variables for Current year, current month and Previous year and Previous month. My month field is in this format 201703, how can I create the variables and use current as the default when opening my qvw?
My field contain year month, for example 201703
I need to write variables for the following
current year_month
previous Month
Previous year,
Also I need to add these for .qvw as the current year month as an open trigger,
What is the best way to create and apply?
Note: Edited by Community Moderator for title brevity.
create a MonthSerial field in script like this
(left(year_month,4)*12) + right(year_month) as MonthSerial
Variables
vCurrentYearMonth= Year(Today())*12 + num(month(today()))
OR
vCurrentYearMonth= max(MonthSerial)
vPreviousMonth=$(vCurrentYearMonth)-1
vPreviousYearMonth=$(vCurrentYearMonth)-12
Singh,
Both vCurrentYearMonth and PreviousMonth work perfectly.
However vPreviousYearMonth returned a false value for the month, when you subtract 12.
What does 'current' mean here? Is it 'current' based on the actual date or based on the maximum value in your year_month field?
What does 'use current as default' mean? Do you want to select a value in your year_month field?
For that you can add a Select in Field action to the OnOpen document triigger. Use year_month for the Field parameter try =Date(Today(),'YYYYMM') or =Date(Max(year_month),'YYYYMM') as Search String
Current is defined as max value for Year_month field