Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
JohannesBoehmer
Contributor II
Contributor II

Calculation of max date and the date before

Hi everyone, 

I´m just learning Qlik Sense and cannot find a solution in here for my problem. I

n my data model I have a Snapshotdate where a snapshot of every budget day is included. Now I´m trying to calculate the change between the most current day and the day before. Therefore I tried to create a variable with max function. 

For example today is 2022-06-17, that means the last snapshot would be 2022-06-16 and the snapshot before 2022-06-13 because of public holiday. 

How can I create two variable which let me calculate the change between these two days?

My try was:

LET vSnapshotDate =max(date#(SnapShotDate,'YYY-MM-DD'),0);

LET vSnapshotDate =max(date#(SnapShotDate,'YYY-MM-DD'),1);

It returns 'Null'

 

Labels (1)
1 Solution

Accepted Solutions
vinieme12
Champion III
Champion III

create variables in front end, not the script

https://www.youtube.com/watch?v=ZORSYf45RNU

 

Name : vMaxSnapshot 

Expression

=Date(max(date#(SnapShotDate,'YYY-MM-DD')))  // with the leading equal sign

 

Name : vPriorSnapshot 

Expression

=Date(max(date#(SnapShotDate,'YYY-MM-DD'),2))  // with the leading equal sign

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

1 Reply
vinieme12
Champion III
Champion III

create variables in front end, not the script

https://www.youtube.com/watch?v=ZORSYf45RNU

 

Name : vMaxSnapshot 

Expression

=Date(max(date#(SnapShotDate,'YYY-MM-DD')))  // with the leading equal sign

 

Name : vPriorSnapshot 

Expression

=Date(max(date#(SnapShotDate,'YYY-MM-DD'),2))  // with the leading equal sign

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.