Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
IcycoolSS
Contributor
Contributor

Load script in QlikSense to load data only for the Max(year)

I have data for multiple Reporting years in my table in Oracle DB called tbl_Sales, I need to load data for only latest year.

I am trying the below script; however, not sure data is not getting loaded in the Final table. Please guide me, I am not able to identify if I have made any silly mistake.


File_status:
LOAD
RPT_YEAR,
SELECT
RPT_YEAR,
FROM "tbl_Sales";


TEMP:
LOAD
Max(RPT_YEAR) as Current_Year
Resident File_status;

LET v_max_year = floor(peek('Current_Year'));

Final:
Load *
Resident File_status
where RPT_YEAR = $(v_max_year);

Drop Table TEMP;

Drop Table File_status;


I am new to Qlik Sense, any help would be much appreciated.

Labels (3)
2 Solutions

Accepted Solutions
hesh
Partner Ambassador
Partner Ambassador

Please try the below code:

File_status:
LOAD
RPT_YEAR,
SELECT
RPT_YEAR,
FROM "tbl_Sales" ;


TEMP:
LOAD
Max(RPT_YEAR) as Current_Year
Resident File_status;

LET v_max_year = floor(peek('Current_Year'));

NOCONCATENATE
Final:
Load *
Resident File_status
where RPT_YEAR = $(v_max_year);

Drop Table TEMP;

Drop Table File_status;

View solution in original post

IcycoolSS
Contributor
Contributor
Author

2 Replies
hesh
Partner Ambassador
Partner Ambassador

Please try the below code:

File_status:
LOAD
RPT_YEAR,
SELECT
RPT_YEAR,
FROM "tbl_Sales" ;


TEMP:
LOAD
Max(RPT_YEAR) as Current_Year
Resident File_status;

LET v_max_year = floor(peek('Current_Year'));

NOCONCATENATE
Final:
Load *
Resident File_status
where RPT_YEAR = $(v_max_year);

Drop Table TEMP;

Drop Table File_status;

IcycoolSS
Contributor
Contributor
Author

@hesh - Thank you!