Skip to main content Skip to complementary content

lunarweekname - script and chart function

This function returns a display value showing the year and lunar week number corresponding to a timestamp of the first millisecond of the first day of the lunar week containing date. Lunar weeks in Qlik Sense are defined by counting January 1as the first day of the week and, apart from the final week of the year, will contain exactly seven days.

Syntax:  

LunarWeekName(date [, period_no[, first_week_day]])

Return data type: dual

Example diagram of lunarweekname() function

Example diagram showing how the lunarweekname function converts an input date into a value displaying a combination of year and lunar week number.

The lunarweekname() function determines which lunar week the date falls into, beginning a week count from January 1. It then returns a value comprised of year/weekcount.

Arguments
Argument Description
date The date or timestamp to evaluate.
period_no period_no is an integer or expression resolving to an integer, where the value 0 indicates the lunar week which contains 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.

When to use it

The lunarweekname() function is useful when you would like to compare aggregations by lunar weeks. For example, the function could be used to determine the total sales of products by lunar week. Lunar weeks are useful when you would like to ensure that all values contained in the first week of the year contain only values from January 1 at the earliest.

These dimensions can be created in the load script by using the function to create a field in a Master Calendar table. The function can also be used directly in a chart as a calculated dimension.

Function examples
Example Result
lunarweekname('01/12/2013') Returns 2006/02.
lunarweekname('01/12/2013', -1) Returns 2006/01.
lunarweekname('01/12/2013', 0, 1) Returns 2006/02.

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. For more information, see Modifying regional settings for apps and scripts.

Default regional settings in apps are based on the user profile. These regional format settings are not related to the language displayed in the Qlik Cloud user interface. Qlik Cloud will be displayed in the same language as the browser you are using.

If you are an app creator, you can set the default region for apps you create. For more information, see Setting your preferred regional settings for creating apps and scripts in Qlik Cloud Analytics.

Example 1 – date with no additional arguments

Example 2 – date with period_no argument

Example 3 – date with first_week_day argument

Example 4 – Chart object example

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!