Skip to main content Skip to complementary content

inlunarweek - script and chart function

This function determines if timestamp lies inside the lunar week containing base_date. Lunar weeks in Qlik Sense are defined by counting January 1 as the first day of the week., Apart from the final week of the year, each week will contain exactly seven days.

Syntax:  

InLunarWeek (timestamp, base_date, period_no[, first_week_day])

Return data type: Boolean

Information note

In Qlik Sense, the Boolean true value is represented by -1, and the false value is represented by 0.

The inlunarweek() function determines which lunar week the base_date falls into. It then returns a Boolean result once it has determined whether each timestamp value occurs during the same lunar week as the base_date.

Diagram of inlunarweek() function

Example diagram of inlunarweek function, showing the dates for which the function will return a TRUE value, given the input information.

When to use it

The inlunarweek() function returns a Boolean result. Typically, this type of function will be used as a condition in an IF expression. This would return an aggregation or calculation dependent on whether the date evaluated occurred during the lunar week in question.

For example, the inlunarweek() function can be used to identify all equipment manufactured in a particular lunar week.

Arguments
Argument Description
timestamp The date that you want to compare with base_date.
base_date Date that is used to evaluate the lunar week.
period_no The lunar week can be offset by period_no. period_no is an integer, where the value 0 indicates the lunar week which contains base_date. Negative values in period_no indicate preceding lunar weeks and positive values indicate succeeding lunar weeks.
first_week_day An offset that may be greater than or less than zero. This changes the beginning of the year by the specified number of days and/or fractions of a day.
Function examples
Example Result
inlunarweek('01/12/2013', '01/14/2013', 0) Returns TRUE, since the value of timestamp, 01/12/2013, falls in the week 01/08/2013 to 01/14/2013.
inlunarweek('01/12/2013', '01/07/2013', 0) Returns FALSE, since the base_date 01/07/2013 is in the lunar week defined as 01/01/2013 to 01/07/2013.
inlunarweek('01/12/2013', '01/14/2013', -1) Returns FALSE. Specifying a value of period_no as -1 shifts the week to the previous week, 01/01/2013 to 01/07/2013.
inlunarweek('01/07/2013', 01/14/2013', -1) Returns TRUE. In comparison with the previous example, the timestamp is in the following week, after into account the shift backwards.
inlunarweek('01/11/2006', '01/08/2006', 0, 3) Returns FALSE. Specifying a value of 3 for first_week_day means that the start of the year is calculated from 01/04/2013. Therefore, the value of base_date falls in the first week, and the value of timestamp falls in the week 01/11/2013 to 01/17/2013.

The inlunarweek() function is often used in combination with the following functions:

Related functions
Function Interaction
lunarweekname - script and chart function This function is used to determine the lunar week number of the year in which an input date occurs.

Regional settings

Unless otherwise specified, the examples in this topic use the following date format: MM/DD/YYYY. The date format is specified in the SET DateFormat statement in your data load script. The default date formatting may be different in your system, due to your regional settings and other factors. You can change the formats in the examples below to suit your requirements. Or you can change the formats in your load script to match these examples.

Default regional settings in apps are based on the regional system settings of the computer or server where Qlik Sense is installed. If the Qlik Sense server you are accessing is set to Sweden, the Data load editor will use Swedish regional settings for dates, time, and currency. These regional format settings are not related to the language displayed in the Qlik Sense user interface. Qlik Sense will be displayed in the same language as the browser you are using.

Example 1 - No additional arguments

Example 2 - period_no

Example 3 - first_week_day

Example 4 - Chart object

Example 5 - Scenario

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!