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: 
prosell8
Contributor II
Contributor II

Data Load Editor trying to return previous 12 months

Hello Qlik Group,

I'm trying to return the last 12 months when loading data from a QVD. I'm able to return previous day but not month. The logic below is what I have but not sure if my syntax is not formatted properly. 

 

vNoOfMonths = 12;
For i = 0 to vNoOfMonths-1
//Let vMonth = Date(AddMonths(Today(),-$(i)),'YYYYMM');// this works for previous day


Let vMonth = Date(AddMonths(Month(),-$(i)),'YYYYMM'); // Returns Error

The following error occurred:
Cannot open file: 'lib://QVD -  (Native Path: *** System error: ***)


Trace $(vMonth);

 

Any help would help, 

Cheers

Labels (1)
1 Solution

Accepted Solutions
prosell8
Contributor II
Contributor II
Author

Found a solution to my issue. 

Let vMonth = Date(AddMonths(AddMonths(today()-1,-1),-$(i)),'YYYYMM');

View solution in original post

3 Replies
hic
Former Employee
Former Employee

Month() must have a parameter.

You probably want a date representing the month. Try MonthStart(Today()) instead. Hence:

Let vMonth = Date(AddMonths(MonthStart(Today()),-i),'YYYYMM'); 

prosell8
Contributor II
Contributor II
Author

Hi,

Thank you for the solution. Unfortunately, it stills brings in October 2023. 

 

prosell8
Contributor II
Contributor II
Author

Found a solution to my issue. 

Let vMonth = Date(AddMonths(AddMonths(today()-1,-1),-$(i)),'YYYYMM');