Skip to main content Skip to complementary content

Derived fields

If you have a group of fields that are related, or if fields carry information that can be broken up into smaller parts that are relevant when creating dimensions or measures, you can create field definitions that can be used to generate derived fields. One example is a date field, from which you can derive several attributes, such as year, month, week number, or day name. All these attributes can be calculated in a dimension expression using Qlik Sense date functions, but an alternative is to create a calendar definition that is common for all fields of date type. Field definitions are stored in the data load script.

Information noteDefault calendar field definitions for Qlik Sense are included in autoCalendar for date fields loaded using Data manager. For more information, see Adding data to the app.

Declare the calendar field definitions

You use the Declare statement to create a definition of the derived fields. This is where you define the different attributes of the field in this case date related attributes. Each field is described as <expression> As field_name tagged tag. Setting one or more tags is optional, but it can affect the sort order of the derived field. Use $1 to reference the data field from which the derived fields should be generated.

Warning note Do not use autoCalendar as name for calendar field definitions, as this name is reserved for auto-generated calendar templates.
Calendar: DECLARE FIELD DEFINITION TAGGED '$date' Parameters first_month_of_year = 1 Fields Year($1) As Year Tagged ('$numeric'), Month($1) as Month Tagged ('$numeric'), Date($1) as Date Tagged ('$date'), Week($1) as Week Tagged ('$numeric'), Weekday($1) as Weekday Tagged ('$numeric'), DayNumberOfYear($1, first_month_of_year) as DayNumberOfYear Tagged ('$numeric');

For more information, see Declare.

Map data fields to the calendar with Derive

The next step is to use the Derive statement to map existing data fields to the calendar. This will create the derived fields. You can do this in three alternative ways in the data load script:

  • Map specific fields by field name.

    DERIVE FIELDS FROM FIELDS OrderDate,ShippingDate USING Calendar;
  • Map all fields with one or more specific field tags.

  • Map all fields that are tagged with one of the tags of the field definition ($date in the example above).


In this case, you could use any of the three examples here.

For more information, see Derive.

Use the derived date fields in a visualization

Qlik Sense is prepared to recognize derived date fields if you have created a calendar definition and mapped the fields like in the example here. They are available in the Date & time fields section of the Fields asset panel. You will also find all derived fields in the expression editor and when you create or edit dimensions.

For more information, see Date & time fields.

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!