Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
 
					
				
		
 dmohanty
		
			dmohanty
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Hi All,
I have a Month field with 12 months values like = Mar-15, Feb-15, Jan-15, Dec-14, Nov-14 etc.
I want to write a script in Load statement, where it would calculate the Last 6 Months of data dynamically.
Ex- When I select Mar-15, then 6 Months of data(Mar-15 - Oct-14) will be calculated and will be displayed in an Object.
When I select Feb-15, then 6 Months of data(Feb-15 - Sep-14) will be calculated and will be displayed in an Object.
I tried using the below clause, but its getting calculated for the particular month (Its not becoming dynamic) :
[Month] >= addmonths(date(MonthName(Today(),0), 'MM/DD/YYYY'),-6)
 and 
[Month] <  addmonths(date(MonthName(Today(),0), 'MM/DD/YYYY'),0)
So this expression is always calculating the data of latest month and previous 6 months.
Could someone please help this to make dynamic.
Regards!
 
					
				
		
 ramoncova06
		
			ramoncova06
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		your backend script does not has a direct relation to the data that gets displayed
QlikView App: Dates, Date Ranges and Set Analysis
here is an option to do this with set analysis
 
					
				
		
hi
try this, hope this will help you.
suppose you have to calculate sale for last 6 month
if(
datefield >= addmonths(date(datefield),-6)
 and 
datefield <  date(datefield),sales)
 maxgro
		
			maxgro
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		PFA

 
					
				
		
 dmohanty
		
			dmohanty
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		My requirement was to make that calculation dynamic in Load script itself.
Don't we have any other solutions/options?
 
					
				
		
 dmohanty
		
			dmohanty
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Thank you Massimo.
Can the same functionality be done in Load Script itself - by any means????
 
					
				
		
 ramoncova06
		
			ramoncova06
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		you can create several dynamic stuff in your script but this is not one of them, whatever you do in your script does not have direct relation with whatever you display in your objects.
maybe the requirement was that in the backend ? if that is the case then I believe Massimo already provided an alternative on to what to do.
I wouldn't go with IF statements to run this since they tend to be slower that doing this at set analysis level
 maxgro
		
			maxgro
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		in the script you can cumulate for every
dim1, yearmonth
the sum of the same dim1, yearmonth-6 +.......+ yearmonth-1 + yearmonth
in the attachment my idea, try to see (and check) if it helps you
but I really don't understand why you want it in the script
 
					
				
		
Hi
Your script is really helpful. But i need next three months from current monthyear.
i have made some changes. That is,
year(date)*12-month(date) as monthid, /* in script
expression is
=sum({$ <year=,month=,monthyear=,monthid={">$(=max(monthid)-3)<=$(=max(monthid))"}>}val)
From these changes i am getting three months but like this. Suppose i have selected dec15 so it is giving me jan14, feb14,dec15. but what i want is next two months along with current selection i.e in my case is dec15, however it is giving me previous two months. i want dec15, jan16, feb16. how can i get this?
Please help.
Thanks
 shraddha_g
		
			shraddha_g
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		sum({$ <year=,month=,monthyear=,monthid={">$(=max(monthid))<=$(=max(monthid)+2)"}>}val)
