Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

pascaldijkshoor
Contributor

Filter on last weeks

Hello,

I want a filter that filters on the last couple of weeks (for example the last 5 weeks). This filter will be used on graphs that compare 2017 with 2018, So I want to compare week 2-6 of 2017 and week 2-6 of 2018 with each other. I tried to use the weeksago function but then it only shows the last 5 weeks in 2018 and not those weeks in 2017.  Does anyone have a solution for this?

Thanks,

Pascal

6 Replies
YoussefBelloum
Esteemed Contributor

Re: Filter on last weeks

Hi,

can you tell us more about your table structure ?

what are the Date columns you have ?

can you attach an example app? sample data ?

pascaldijkshoor
Contributor

Re: Filter on last weeks

I have bar chart with week dimensions on the X-axis (W01, W02, W03,...) and a measure that calculates the difference between 2017 and 2018 on the Y-axis.

YoussefBelloum
Esteemed Contributor

Re: Filter on last weeks

this Week dimension (W01, W02...) is it a derived field of a "formatted" "date field?

Highlighted
pascaldijkshoor
Contributor

Re: Filter on last weeks

Yes it is

YoussefBelloum
Esteemed Contributor

Re: Filter on last weeks

Hi,

here you can find one method to do it

=sum({<Year={'$(=Max(Year))'}, Week={">=$(=Week(today())-5)<$(=Week(today()))"}>}myRandom) ==> for last 5 weeks of N

=sum({<Year={'$(=Max(Year)-1)'}, Week={">=$(=Week(today())-5)<$(=Week(today()))"}>}myRandom) ==> for last 5 weeks of N-1

Please find attached

YoussefBelloum
Esteemed Contributor

Re: Filter on last weeks

and with this one you have can change dynamically the numbers of the weeks

please find attached