week - script and chart function

This function returns an integer representing the week number according to ISO 8601. The week number is calculated from the date interpretation of the expression, according to the standard number interpretation.

Syntax:  

week(timestamp [, first_week_day [, broken_weeks [, reference_day]]])

 

Return data type: integer

Argument Description
timestamp The date to evaluate as a timestamp or expression resolving to a timestamp, to convert, for example '2012-10-12'.
first_week_day

If you don't specify first_week_day, the value of variable FirstWeekDay will be used as the first day of the week.

If you want to use another day as the first day of the week, set first_week_day to:

  • 0 for Monday
  • 1 for Tuesday
  • 2 for Wednesday
  • 3 for Thursday
  • 4 for Friday
  • 5 for Saturday
  • 6 for Sunday

The integer returned by the function will now use the first day of the week that you set with first_week_day.

FirstWeekDay

broken_weeks

If you don't specify broken_weeks, the value of variable BrokenWeeks will be used to define if weeks are broken or not.

By default Qlik Sense functions use unbroken weeks. This means that:

  • In some years, week 1 starts in December, and in other years, week 52 or 53 continues into January.
  • Week 1 always has at least 4 days in January.

The alternative is to use broken weeks.

  • Week 52 or 53 do not continue into January.
  • Week 1 starts on January 1 and is, in most cases, not a full week.

The following values can be used:

  • 0 (=use unbroken weeks)
  • 1 (= use broken weeks)

BrokenWeeks

reference_day

If you don't specify reference_day, the value of variable ReferenceDay will be used to define which day in January to set as reference day to define week 1. By default, Qlik Sense functions use 4 as the reference day. This means that week 1 must contain January 4, or put differently, that week 1 must always have at least 4 days in January.

The following values can be used to set a different reference day:

  • 1 (= January 1)
  • 2 (= January 2)
  • 3 (= January 3)
  • 4 (= January 4)
  • 5 (= January 5)
  • 6 (= January 6)
  • 7 (= January 7)

ReferenceDay

Did this information help you?

Thanks for letting us know. Is there anything you'd like to tell us about this topic?

Can you tell us why it did not help you and how we can improve it?