6 Replies Latest reply: May 31, 2017 1:00 AM by Hardik Patel RSS

    New time calculations in 3.2

    Birkir Bjornsson

      Hi all,

       

      Has someone played around with the new time calculation in 3.2? I tried to use it in an app I created and it stated No date fields detected. Does this only work with autocalendar, and If so how could I get it to work with an app I created?

       

      I attached an screenshot

       

      Regards

      Birkir

        • Re: New time calculations in 3.2
          Steve Rosebrook

          I'm having the same issue.  I definitely have date fields in the data model - and they have been formatted specifically with the Date function (in the data load script).  I have tried adding the date field as a dimension as well, but that didn't work either.  How is this new functionality actually supposed to work?

          • Re: New time calculations in 3.2
            Stephanie Warner

            Hi All,

             

            I'm not sure if this helps at all but, something I have been looking into as well.

             

            Regards,

            Stephanie

             

             

             

            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.

            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.

            Calendar:

            DECLARE FIELD DEFINITION TAGGED '$date'

                 Parameters

                     first_month_of_year = 1

                 Fields

                      Year($1) As Year Tagged '$year',

                      Month($1) as Month Tagged '$month',

                      Date($1) as Date Tagged ('$date', '$day'),

                      Week($1) as Week Tagged '$week',

                      Weekday($1) as Weekday Tagged '$weekday',

                      DayNumberOfYear($1, first_month_of_year) as DayNumberOfYear Tagged ('$numeric');

             

            See: Declare  

            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 ways:

            • Map specific fields by field name.DERIVE FIELDS FROM FIELDS OrderDate,ShippingDate USING Calendar;
            • Map all fields with one or more specific field tags.DERIVE FIELDS FROM EXPLICIT TAGS '$date' USING Calendar;
            • Map all fields that are tagged with one of the tags of the field definition ($date in the example above).DERIVE FIELDS FROM IMPLICIT TAG USING Calendar;

            See: Derive  

            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.

            • Re: New time calculations in 3.2
              Hardik Patel

              Hi birkirbjorns,

               

              One of the most important requirement/prerequisite to use this feature is to have date fields loaded through Data Manager and not through Qlik Sense Scripts as highlighted in the screenshot below.

               

              Calendar_Measure_functionality.PNG

               

              This means that data should be loaded through Data Manager. Or, at least those data containing dates for which one wants to build measures or dimensions, must be loaded through Data Manager. Rest of the data or other script code can be added to other sections of Data Load Editor.

               

              Also, data loaded through Data Manager will appear in script as shown in below screenshot.

              Data_Manager_Data_Load_Editor.PNG

              Hope that helps !

               

              Best,

              Hardik