Qlik Community

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

IMPORTANT security patches for GeoAnalytics Server available to download: READ DETAILS
Showing results for 
Search instead for 
Did you mean: 
Contributor III
Contributor III

I need help to get last quarter data dynamically


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!

1 Reply
Master III
Master III

Let vStartDate = QuarterStart(AddMonths(Today(),-3));

Let vEndDate = QuarterEnd(AddMonths(Today(),-3);

Load *;

Select *

From YourTable

Where YourDate BETWEEN ('$(vStartDate)' and '$(vEndDate)')

Note that you may need to play around with the exact syntax and date formatting to get this to work correctly, but that's the gist of it.