Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

last 4 weeks calculation

Hi All,

RangeAvg (
aggr( sum({<Year = {$(=vCurrentYear)},Week ={">= $(=vCurrentWeek-4)<= $(=vCurrentWeek-1)"}>} TRX_NET_SALES), WeekStart,ITEM_SKU))

Issue: the above condition works fine until current week is not one what if its one then it will return -3, 0

So we have to write an expression where it will work fine even though the current week is one and also it should work well even wen an year is having 52 weeks or leap year 53 weeks, so please write an expression accordingly.

example:if we are in 2016 first week it should also calculate 52,51,50,49 like that

can you please help me on this

Regards,

Devendar

3 Replies
maxgro
MVP
MVP

maybe adding a week serial field,

Re: select data of last 4 weeks.

Jason_Michaelides
Luminary Alumni
Luminary Alumni

Look at Richard Pearce's document on calendar with flags. Much easier to create any comparative date period. 


https://community.qlik.com/docs/DOC-6593


Hope this helps,


Jason