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: 
ioannagr
Creator III
Creator III

help with if statement in script variables

Hi, I just wanted you to see what I have come up with this script bit. As you can see from my notes, I want to load the max timestamp in my data then compare it to now timestamp and  load the data according to this vDate IF statement I did.

 

Max_Date:

Load timestamp(max(DayStart([date timestamp])), 'DD/MM/YYYY hh:mm:ss.ffffff') as MaxDate //with this i want to load the max date timestamp in my dataset with 00:00:00.00000 timestamp
from [$(vPathQVD)Sales.qvd] (qvd);

let vNow = Now(); // with this i want to get today's timestamp

Let vCorrectDate=If(MaxDate<vNow, date(floor(MaxDate-1)), date(floor(MaxDate)));  // with this i want to compare timestamp MaxDate with Now() timestamp and if maxDate<vNow holds, then return me the previous of the MaxDate floored, else floored MaxDate

sales:
LOAD
"ID product",
"amount sold",
"availability"
"date timestamp"
FROM [$(vPathQVD)Sales.qvd]
(qvd)
where Date(Floor("date timestamp"),'DD/MM/YYYY') <='$(vDate)';  //so as to load data according to vCorrectDate

 

Is my thinking correct? Do you see any mistakes? Should I add something else?

Thank you in advance.

10 Replies
MayilVahanan

Hi @ioannagr 

Fyip: Comparing number format is very effective & flexible when compare to date / timestamp format..

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.