Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Manish_Sharma
Contributor
Contributor

Data refresh quarterly

I need help to get last quarter data dynamically

Hi,

 

My Qlik report is a quarterly report and this report will get refreshed every quarter. When i am loading the data from database , I want to pull last quarter data dynamically in load script itself. For ex: We are currently in Last quarter of 2022 , Now I want to pull the last quarter data which is 2021-07-01(July) to 2021-09-30(Sep) . Next when Qlik report get refreshed on Jan01 2022 then Dynamically it should pull last quarter data which is from Oct 01-2021 to Dec 31 -2021 data. Can some one help me how to achieve this in load script. Thanks!

Labels (1)
1 Solution

Accepted Solutions
SterreKapteijns
Partner - Creator
Partner - Creator

Are you only interested in the current quarter information? So would a full load of the current quarter be enough or do you want to load incrementally? If you only need the full load of the current quarter you could do something like this: 

 

LET vToday = Today(); 
LET vCurrentYear = Year($(vToday)); 
LET vCurrentMonth = Month($(vToday)); 

LET vCurrentQuarter = Ceil($(vCurrentMonth) / 3);

LET vQuarterStart = MakeDate($(vCurrentYear), (($(vCurrentQuarter)-1)*3)+1, 1);
LET vQuarterEnd = MonthEnd(MakeDate($(vCurrentYear), $(vCurrentQuarter)*3, 1));


LOAD
*
FROM [your_data_source]
WHERE YourDateField >= $(vQuarterStart) AND YourDateField <= $(vQuarterEnd);

View solution in original post

1 Reply
SterreKapteijns
Partner - Creator
Partner - Creator

Are you only interested in the current quarter information? So would a full load of the current quarter be enough or do you want to load incrementally? If you only need the full load of the current quarter you could do something like this: 

 

LET vToday = Today(); 
LET vCurrentYear = Year($(vToday)); 
LET vCurrentMonth = Month($(vToday)); 

LET vCurrentQuarter = Ceil($(vCurrentMonth) / 3);

LET vQuarterStart = MakeDate($(vCurrentYear), (($(vCurrentQuarter)-1)*3)+1, 1);
LET vQuarterEnd = MonthEnd(MakeDate($(vCurrentYear), $(vCurrentQuarter)*3, 1));


LOAD
*
FROM [your_data_source]
WHERE YourDateField >= $(vQuarterStart) AND YourDateField <= $(vQuarterEnd);