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

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Filter only 4 weeks

Kindly guide me in below logic. Is it possible to implement it or not?. If yes please help me

In the dashboard, I want to show only four weeks based on the below situations

1. The Week first day is Friday and last day is Thursday

2. In the dimension there will be and only four weeks For E.g.

Scenario for this week:

12/25 - 12/31 - 1 Week

1/1 - 1/7 - 2 Week

1/8 - 1/14 - 3 Week

1/15 - 1/21 - 4 Week

Next Week Scenario:

1/1 - 1/7 - 1 Week

1/8  - 1/14 - 2 Week

1/15 - 1/21 - 3 Week

1/22 - 1/28 - 4 Week

And same goes on.. The current week goes to 4 Week and basis of that the last 3 week calculate

Thanks a lot for your help. Really appreciate it

Thanks

Deepanshu

11 Replies
marcus_sommer

You could use a simple script like the following to create a master-calendar with a non-calendar week and a weekcounter which based on it:

let vStart = '01.01.2015';

let vEnd = '31.12.2016';

let vCount = num('$(vEnd)') - num('$(vStart)');

for i = 0 to $(vCount)

    Calendar:

    Load

        date('$(vStart)' + $(i), 'DD.MM.YYYY') as Date,

        weekday(date('$(vStart)' + $(i), 'DD.MM.YYYY')) as Weekday,

        week('$(vStart)' + $(i)) as Week,

        month('$(vStart)' + $(i)) as Month,

        year('$(vStart)' + $(i)) as Year,

        week(WeekStart('$(vStart)' + $(i), 0, 4)) as NonCalendarWeek,

        autonumber(week(WeekStart('$(vStart)' + $(i), 0, 4)) & '|' & year('$(vStart)' + $(i))) as WeekCounter

    AutoGenerate 1;

next

and then you could use a set analysis approach like above mentioned:

sum({< WeekCounter = {">=$(=max(WeekCounter)-4)"}>} YourValues)

Note: the Week and NonCalendarWeek might need some adjustments regarding to their start and behaviour by a year-switch to your needed logic. Often is a simple if-loop enough to get the required logic. Also you might prefer another date-format.

- Marcus

marcus_sommer

Here are more useful informations:

Redefining the Week Numbers

Redefining the Week Start

- Marcus