Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Mohammed_Sohail
Contributor
Contributor

How to load last 6 months of data from a folder

Hi Everyone,

I have a folder with 3 years of data (monthly exports .csv files) there are total 36 files in the folder and names of files are Sales_Jan2023, Sales_Feb2023,Sales_Mar2023.

I am trying to load only the latest 6 months of data out of 36 files, How Can I do that, please help.

Labels (3)
2 Replies
Jack_Guo
Support
Support

Hi @Mohammed_Sohail , 

as you don't have too much data files in the folder. Why not  manually combine 6 months csv files to one csv file then load to Qlik Sense app?

 

Vegar
MVP
MVP

Let latest_period_date = today(); //a date represented in the latest period file

Let no_of_months = 6;

For _month_no = 0 to no_of_months-1 do

let _period = date(addmonths('$(latest_period_date)',-$('_month_no)'),'MMMYYYY');

LOAD * 

FROM [Lib://data/Sales_$(_period).csv (txt,...);

Set _period=;

Next _month_no