HOW TO CREATE A DATE RANGE​

To know the various way of creating date ranges in the Qlik sense. First, we need to be clear about what is the date range.

What is the date range

The date range is multiple dates with a specific start date, a specific end date, and all subsequent dates.

As a Qlik Sense developer lot of time, we got the requirement for the data (report) of a particular date range.

      The requirement could be two types of date ranges:

       1. Static (unchangeable) date range.
       2. Dynamic (changeable) date range.

there are many ways where we can provide the report or visualization for the date range as per the requirement. this requirement can be easily fulfilled by the Qlik sense development service or by hiring Qlik sense developer.

Ways to create date ranges:

Some of them are as follows:

  1. Through script
  2. Through set analysis(variable)
  3. Through the filter
  4. Through date range picker

1. SCRIPT

we can achieve the report for the date range or create a date range with the use of the scripting (in the backend) so it will provide the data or report for that date range, but it would be static in nature in the frontend as we can see only those data (in the frontend or in the dashboard) which will be for the date range.

In other words, this process can be called loading the data within the date range or with date conditions.

Example:

There is the data of the employee in which birth dates of the employees are available. In that, we have employees who were born between 1929 and 1971.

but if the requirement is to get only those employees who are born between 1955 and 1964. then we can use the date range in the script.

Steps to create the date range in the script:

  1. Extraction of the data (from oracle or extractor or through attachment (excel file)).
  2. After extracting the data Use where a condition for the range selection or creation.

sample report:

Here min and max birthdates are:

sample report:

2.We have the requirement to get only those employees who are born between 1955 and 1964. so here we can use the date range with the where condition for the same requirements.

this will provide a report of those employees who were born between the date range:
the following is the result:

Result report:

2. Set analysis:


We can also achieve the data for a particular date range or create a date range with the help of set analysis.

In this, we have 2 ways for the set analysis those are as follows:

  1. Direct (Put the date range directly in the syntax or expression).
  2. Indirect (Use the variable in the syntax or expression of the set analysis).

Example:

There is the data of the employee in which birth dates of the employees are available. In that, we have employees who were born between 1929 and 1971.

But we have a requirement to get the sum of the salary of those employees who were born between 1955 to 1964 date range.

Steps to create a date range in the set analysis:

(create the new field with set analysis expressions those are as follows)

1. without the use of a variable (Direct) :

2.with the use of the variable (Indirect):

Here the value of the variable is:

From both set analysis expressions, we would achieve the same result report in the selected salary field which is as follows.

3. Filter:

With the use of the date field filter, we can also achieve the requirements for the date range or can create the date range.
in this, we can select the date range with the use of the filter. so that users can easily view the data for that date range it is dynamic in nature as users can easily change the date range as per their requirement.

Example:
There is the data of the employee in which birth dates of the employees are available. In that, we have employees who were born between 1929 and 1971.

But we have a requirement to get the sum of the salary of those employees who were born between 1955 to 1964 date range.

Steps to create or select the date range in the filter:

  1. We just need to create the filter (with the use of the date field).
  2. Simply in that filter we can put the date range i.e., >=start date<=end date, and press Enter.
  3. All those dates will be selected.

(Just Make sure that the date Format for the start date and end date should match the dates from Date Field)



This will select the range and will provide data for that range only:

Result report:

4. Date range picker:

We can also achieve the data for a particular date range or create a date range with the help of a date range picker as per the requirement.
Users can choose a single date or a range of dates from a calendar using the date range picker (Date Picker).

The date selector has two modes:

  • single-date mode.
  • interval mode.

In this Data-related dates are highlighted in black on the calendar. Dates without any accompanying information are greyed out. it is also dynamic in nature.

Example:
we have data on the sales of the company in which order dates are available where min order date is 02/02/2010 and the max order date is 05/22/2017.
but we want to know the profit of those sales only which were ordered between 02/02/2010 to 28/05/2010

Steps to create or select a date range in the date range picker:
1. On the sheet you are editing, you can add a date picker.

Act as follows:

Drag a Date Picker object to the sheet by opening Custom objects > Dashboard bundle in the assets panel.

Select if you want to be able to pick a single date or a date interval in Single date/interval.

You can select a range of dates using date intervals.

You can choose just one date with a single date.

2. When you have created the date range picker.

it will appear as follows:

Result report:

>  Other additional features or settings of the date range picker:
you may want to adjust its appearance and other settings as follows:

>  Setting the available date range:
By turning on the Advanced setup option, you can specify the range of dates that are available for selection. You have the option of using date values or expressions. A field called Date Field is referred to in the expressions that follow.

Set the first date of the calendar with the Min date.

The predetermined value is =Min (1 [Date Field]). The first date in the entire data set’s Date Field is returned by this expression.

Set the last date of the calendar with the Max date.

Max (1 [Date Field]) is the default value. The last date in the entire data set’s Date Field is returned by this expression.

  • Setting locale of the calendar:
     You can set the locale of the calendar to get local names for days and months. The two-letter code for the locale you intend to use should be entered in the Locale setting under Calendar Settings > Language and labels. You may switch the default value of en for English to de for German, for instance.
  • Predefined ranges:

    If you turned on predefined ranges, you could choose from a variety of predetermined ranges in date interval mode. With the settings found under Calendar Settings > Predefined ranges, you can change the text labels for the predefined range selections.

    The option known as Custom Range allows you to freely choose a date range from the calendar. Value by default is range.

  • Text labels:
    When using the date range picker, the text labels that are displayed can be changed. With the Default Text setting found under Calendar Settings > Language and labels, you can modify the text that appears when the date range picker is minimized. “Select date range” is the default setting.



Conclusion:

from the above content, we can conclude that date range requirements are so general and often demanded by the clients which can be easily fulfilled by the Qlik sense development service or by hiring a Qlik sense developer with the use of various ways such as through scripting, filter, set analysis and most used & attractive way is through date range picker.