Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
pascaldijkshoor
Creator
Creator

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
Champion
Champion

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
Creator
Creator
Author

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
Champion
Champion

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

pascaldijkshoor
Creator
Creator
Author

Yes it is

YoussefBelloum
Champion
Champion

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
Champion
Champion

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

please find attached