Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT

Calendars

cancel
Showing results for 
Search instead for 
Did you mean: 
hic
Former Employee
Former Employee

Calendars

Last Update:

Sep 21, 2022 1:04:33 PM

Updated By:

Sue_Macaluso

Created date:

Jul 4, 2016 10:23:21 AM

Attachments

A calendar is very useful when you want to link your data to different time periods, e.g. when you want to display your KPIs over different years or months. Often you only have one date and you just want to use a standard calendar. For this case, there are plenty of resources on this community. You can find a good overview on How to use - Master-Calendar and Date-Values..

If you have several date fields, you should most likely have several calendars defined in your script. See

Why You sometimes should Load a Master Table several times

Canonical Date

If you want to use a non standard calendar, like a fiscal calendar or a 4-4-5 calendar, the challenge becomes more difficult. See e.g. Fiscal Yearor Recipe for a 4-4-5 Calendar‌.


The script posted here will help you create a more complicated calendar. It has parametrized examples for the following calendars:

  • Standard Gregorian month-based calendar
  • Standard Gregorian week-based calendar
  • Standard Gregorian week-based calendar with broken weeks
    The first and last weeks of the year do not span the shift of the year and they do not necessarily have 7 days
  • Month-based fiscal calendar
    The Gregorian months are used as fiscal months, but January is not necessarily the first month of the fiscal year.
  • Week-based 4-4-4 calendar
    The fiscal year is divided into 13 months with 4 weeks each. Occasionally there is a 14th month with one week.
  • Week-based 4-4-5 calendar
    The fiscal year is divided into 4 quarters, each with 3 months. The first month of the quarter has 4 weeks, the second has 4 weeks, and the last has 5 weeks. Occasionally the last month of the year has an additional week.
  • Week-based 4-5-4 calendar
    The fiscal year is divided into 4 quarters, each with 3 months. The first month of the quarter has 4 weeks, the second has 5 weeks, and the last has 4 weeks. Occasionally the last month of the year has an additional week.
  • Week-based 5-4-4 calendar
    The fiscal year is divided into 4 quarters, each with 3 months. The first month of the quarter has 5 weeks, the second has 4 weeks, and the last has 4 weeks. Occasionally the last month of the year has an additional week.
  • Broadcast calendar
    The months are week-based and start on the first day of the week that contains the first day of the Gregorian month.

There are several parameters that you can use to configure your calendar: The first month of the year, the first day of the week and the first week of the week-based year.

The script is commented, so hopefully you can read it and understand it. You can paste it straight into an empty app and run it to evaluate how it works. If you want to use parts of it inside one of your own apps, you may need to rename some fields.

The script should work in both Qlik Sense and QlikView.

Good Luck!

HIC

Comments
poooja
Creator
Creator

Hi Henric,

Hope you can help me on the Below.

My source has sales & budget data so it has order date, Transaction date and budget date. Please help me with some logic for the below scenario .

1. How to find 'Total Number of weeks in the current month'. Week starts from Monday.If the week has started already it should be considered as same week irrespective of the new month start. If the month starts on middle of the week that should consider as last week of the previous month.I am able to achieve but not as desired.

(Answer is: Jan 5 weeks,Feb 4 weeks,Mar 4 weeks,Apr 5 weeks, May 4 weeks,June 4 weeks, July 5 weeks,Aug 4 weeks,Sep 4 weeks,Oct 5 weeks,Nov 4 weeks,Dec 5 weeks,)

Result what i am getting is : Feb 5 weeks, March 6 weeks but it should be 1 week less because Feb 1 false under last week of January and march 1 falls under last week of Feb.

2. Max(OrderDate) falls in which week of the current month.
Ex: if OrderDate 3/1/2019 this is falls in 4th week of Feb.

I have attached the QVW.   in the below link.

Total Number of-weeks in the current month

Thanks!

Pooja

jorgie
Contributor II
Contributor II

Hi to all!

 

Amazing script, but as a newbie in qlik world I would like some assistance about setting the dates.

I used the 445 week part, when I selected the year 2022 I got first date 28/08/2022 and last 26/08/2023.

What changes I should do?  I want to use the 445 rule but year starts at Jan and finishes at Dec.

 (if it has been answered already I am sorry but I didn't understand it obviously....)

 

Thank you for your time

Contributors
Version history
Last update:
‎2022-09-21 01:04 PM
Updated by: