Discussion Board for collaboration related to QlikView App Development.
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)
[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.
your backend script does not has a direct relation to the data that gets displayed
here is an option to do this with set analysis
try this, hope this will help you.
suppose you have to calculate sale for last 6 month
datefield >= addmonths(date(datefield),-6)
datefield < date(datefield),sales)
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
in the script you can cumulate for every
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
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
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?