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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Loading Data From Years Prior to Max

Hey, I've just started using Qlik Sense and I'm having troubles loading data using the data loader.

I've been scripting everything fine so far but I've been having trouble with one piece of the script in regards to loading data on a given interval. Currently i have the following code:

//LET RefDate = (MAX(NUM(Month(OrderDate),00)&Year(OrderDate))-3);

LOAD CustomerID,

    EmployeeID,

    Freight,

    OrderDate,

    NUM(Month(OrderDate),00)&'-'&Year(OrderDate) AS MonthDate,

    OrderID,

    ShipperID

    WHERE YEAR(OrderDate)>=(MAX(YEAR(OrderDate))-3);

SQL SELECT *

FROM Orders;

//WHERE YEAR(OrderDate)>=(MAX(YEAR(OrderDate))-3)

//WHERE OrderDate>=(LatestDate-3);

It's throwing an exception on all of those methods tried and i'm kinda lost since i understand how to do it using SQL but whenever i declare a variable it doesn't recognize it in the SQL part and whenever I try to do the Where statement in the SQL part I'm lacking the commands to create the range since I can't declare variables in the SQL commands.

What i'm trying to do is find the max date of the data set, possibly concat the month and date together and then subtract 3 from that number. In doing so, i hope to be a be able to set up an interval to test my OrderDate values in order to work with that range. Any ideas?

0 Replies