Skip to main content Skip to complementary content

inquarter - script and chart function

This function returns True if timestamp lies inside the quarter containing base_date.

Syntax:  

InQuarter (timestamp, base_date, period_no[, first_month_of_year])

Return data type: Boolean

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

Diagram of inquarter() function's range

Diagram that shows the range of time that the inquarter() function evaluates.

In other words, the inquarter() function divides the year into four equal quarters between January 1 and December 31. You can use the first_month_of_year argument to change what month is considered the first in your app, and the quarters will change based on that argument. The base_date, the function identifies which quarter should be used as the comparator for the function. Finally, the function returns a Boolean result when comparing date values to that quarter segment.

The inquarter() function returns a Boolean result. Typically, this type of function will be used as a condition in an if expression. This returns an aggregation or calculation that depends on whether a date occurred in the selected quarter.

For example, the inquarter() function can be used to identify all equipment manufactured in a quarter segment based on the dates when the equipment was manufactured.

Arguments
Argument Description
timestamp The date that you want to compare with base_date.
base_date Date that is used to evaluate the quarter.
period_no

The quarter can be offset by period_no. period_no is an integer, where the value 0 indicates the quarter which contains base_date. Negative values in period_no indicate preceding quarters and positive values indicate succeeding quarters.

first_month_of_year If you want to work with (fiscal) years not starting in January, indicate a value between 2 and 12 in first_month_of_year.

You can use the following values to set the first month of year in the first_month_of_year argument:

first_month_of_year values
Month Value
February 2
March 3
April 4
May 5
June 6
July 7
August 8
September 9
October 10
November 11
December 12

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.

Function examples
Example Result
inquarter ('01/25/2013', '01/01/2013', 0) Returns TRUE
inquarter ('01/25/2013', '04/01/2013', 0) Returns FALSE
inquarter ('01/25/2013', '01/01/2013', -1) Returns FALSE
inquarter ('12/25/2012', '01/01/2013', -1) Returns TRUE
inquarter ('01/25/2013', '03/01/2013', 0, 3) Returns FALSE
inquarter ('03/25/2013', '03/01/2013', 0, 3) Returns TRUE

Example 1 - No additional arguments

Example 2 - period_no

Example 3 - first_month_of_year

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!