Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Only at Qlik Connect! Guest keynote Jesse Cole shares his secrets for daring to be different. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to Use Current Variable as the Default When Opening .qvw?

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.

4 Replies
shubham_singh
Partner - Creator II
Partner - Creator II

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

Not applicable
Author

Singh,

Both vCurrentYearMonth and PreviousMonth work perfectly.

However vPreviousYearMonth returned a false value for the month, when you subtract 12.

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

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


talk is cheap, supply exceeds demand
Not applicable
Author

Current is defined as max value for Year_month field