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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Saving the maximum date from script in own variable

Hi,

I need some help...

I have a script loading some data, DATE is one of the fields loaded. Those dates are not sequential, sometimes the difference between 2 dates could be 7 days, sometimes 2 days. I would like to create in this script 2 my own variables:

DATE1 - with the maximum date present in DATE variable

DATE2 - with 31-12-"present year" to the one represented by the maximum date from DATRE (in 100% cases present year to the max date from DATE would be present year to today())

Seams easy, but as I am not so familiar with date fuctions in a script, I just do not know how to handle

Thanks for any help

1 Solution

Accepted Solutions
derekjones
Creator III
Creator III

Hi draszor

Ok, I would create the variables in the qvw itself...

DATE1 = Max(DATE)

DATE2 then uses the variable DATE1 to ascertain the max year, then uses it as follows:

DATE2 = Date('31/12/'&Year(DATE1))-DATE1

I've attached a simple example to help you...

Derek

View solution in original post

2 Replies
derekjones
Creator III
Creator III

Hi draszor

Ok, I would create the variables in the qvw itself...

DATE1 = Max(DATE)

DATE2 then uses the variable DATE1 to ascertain the max year, then uses it as follows:

DATE2 = Date('31/12/'&Year(DATE1))-DATE1

I've attached a simple example to help you...

Derek

Not applicable
Author

Hi,

Thanks a lot for this hint. I did not know that QV allows to create own variales in the report, and was thinking that all this stuff needs to be created in the script.

Because Date2 was appearing as 156 and not 31/12/2010, I corrected it into:

DATE2 = Date('31/12/'&Year(DATE1-360))

Thanks a lot once more

Robert