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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Variable Issue

I want to load data belonging to the latest batch of data.

I created a max date for data i receive form a database.

MaxDate:

Load Max(Date(Date#(MONTH_BATCH,'YYYY-MM'),'YYYY-MM')) as MaxDate

resident Test ;

Let vMaxDate = Date(Date#(peek('MaxDate', -1),'YYYY-MM'),'YYYY-MM')

When I load the data form the qvd with all the data, I plan to use the vMaxDate variable in the where clause.

The variable returns the right value ie., '2012-05' when i check it in a text box with the expression '=vMaxDate'

But when I use =$(vMaxDate), the value it returns is 2007.

What could be the issue here?

1 Reply
tomhoch1
Partner - Contributor II
Partner - Contributor II

Hi Bharath,

Your date is being evaluated as string so when you expand the variable vMaxDate QV is interpreting it as 2012 - 5 which equals 2007.

To have it evaluate to a date remove the date function like this:

MaxDate:

Load Max(Date#(MONTH_BATCH,'YYYY-MM'),'YYYY-MM') as MaxDate

resident Test ;

And to set it to the variable:

Let vMaxDate = peek('MaxDate', 0);

The variable will then be 41030 which is May 1, 2012.