Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
 prosell8
		
			prosell8
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		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
Trace $(vMonth);
Any help would help,
Cheers
 prosell8
		
			prosell8
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Found a solution to my issue.
Let vMonth = Date(AddMonths(AddMonths(today()-1,-1),-$(i)),'YYYYMM');
 
					
				
		
.png) hic
		
			hic
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		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
		
			prosell8
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Hi,
Thank you for the solution. Unfortunately, it stills brings in October 2023.
 prosell8
		
			prosell8
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Found a solution to my issue.
Let vMonth = Date(AddMonths(AddMonths(today()-1,-1),-$(i)),'YYYYMM');
