Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
Talk to Experts, a LIVE Q&A Webinar. Bring your Qlik Sense Business questions on Aug. 4th. Register
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Contributor III
Contributor III

Need to load data only for max(year) in QlikSense load script

Hi All,

I have data for multiple Reporting years in my oracle table year_sales, I need to load data for only latest year. I am trying below script, however, not sure data is not getting loaded in 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 "Year_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;

 

Thanks in advance.

 

Regards,

Onkar Kulkarni

1 Solution

Accepted Solutions
Highlighted
Partner
Partner

Re: Need to load data only for max(year) in QlikSense load script

Hi

Use the below code:

File_status:
LOAD
RPT_YEAR,
SELECT
RPT_YEAR,
FROM "Year_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

4 Replies
Highlighted
Partner
Partner

Re: Need to load data only for max(year) in QlikSense load script

Hi

Use the below code:

File_status:
LOAD
RPT_YEAR,
SELECT
RPT_YEAR,
FROM "Year_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

Highlighted
Contributor III
Contributor III

Re: Need to load data only for max(year) in QlikSense load script

You may simply restrict the year while fetching from Oracle, e.g.

...

SELECT
   RPT_YEAR
FROM "Year_sales"
WHERE RPT_YEAR = EXTRACT(YEAR FROM SYSDATE)

Highlighted
Creator II
Creator II

Re: Need to load data only for max(year) in QlikSense load script

Hi,

 

Try This

 

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


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

LET v_max_year = peek('Current_Year');

Drop Table TEMP;

Drop Table File_status;

Final:
Load *
FROM "Year_sales"
where RPT_YEAR = $(v_max_year);

 

Thanks,
Naresh

 

Highlighted
Contributor III
Contributor III

Re: Need to load data only for max(year) in QlikSense load script

Thanks for the quick reply. I cannot use sysdate as not necessary the max (year) will be sysdate year.  sometimes latest year could be 2015 in data.