Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Catch up on the newest Qlik features and improvements: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
rajtechnocraft
Creator
Creator

find aggr of a value of past 1 year.

Hi all,

I want to extract sum of value of past 1 year from selected date in qlikview 9 .

i am using this :

sum({<RollingMonth = {"$(='<='&Only(RollingMonth)&'>'&Only(date(addmonths(RollingMonth,-13),'MMM-YYYY')))"}>} Value )

My Financial Year starts from October to September

If i select September 2009 then it should show me aggregated value from Oct2008 till Sep2009.

My Expression works fine for calender year Jan to Dec

But it fails for Fin Year Starting from Oct to Sept

help me out in this..

Labels (1)
2 Replies
Not applicable

I asuume your rolling month looks someting like Sep-2009
When you are loading the script it looks like
Load
date(monthstart(Date),'MMM-YYYY') as RollingMonth,
etc
FROM table x;

You can then create two variables

vDate1=date(addmonths(RollingMonth,-11),'MMM-YYYY')
vDate2=RollingMonth


Your list box or selection field is based on RollingMonth

Then you can use the following expression in the report/chart

=sum({$<RollingMonth={">=$(#vDate1)<=$(#vDate2)"}>} Value)

So no matter what month-year you select the expression will alway total 12 months of data i.e. if you select Feb-2009 it will sum Mar-2008 to Feb-2009 etc

johnw
Champion III
Champion III

I'm not seeing anything strictly wrong with what you wrote. I normally use two dollar sign expansions for the range instead of one. I'd also put the second only() around Rolling Month, not around the final expression. I also usually do my expressions based on the maximum date, so that you don't have to select anything, or can select multiple months, and it will still show you something. I doubt any of that will make a difference, but here's what you'd end up with:

sum({<RollingMonth={">$(=date(addmonths(max(RollingMonth),-12),'MMM-YYYY')) <=$(=max(RollingMonth))"}>} Value)

Assuming you have other date fields in the same calendar, you may also need to tell QlikView to ignore them:

sum({<RollingDate=,RollingYear=,RollingMonth={">$(=date(addmonths(max(RollingMonth),-12),'MMM-YYYY')) <=$(=max(RollingMonth))"}>} Value)