4 Replies Latest reply: Feb 2, 2017 8:14 AM by Aehman K RSS

    How to rename autocalendar fields

    Magnus Buseth

      Hi,

       

      I'm using the auto-generated calendar in Qlik Sense and want to rename the field names to make them more user-friendly.

       

      The default names are [Date.autoCalendar.Year], [Date.autoCalendar.Month] etc, and I would like to rename them to just Year, Month etc.

       

      I tried using RENAME FIELDS, but I doesn't seem to do anything.

       

      Can anyone help?

       

      Here's the script that generates the calendar and my attempt at renaming the fields:

       

      [autoCalendar]:

        DECLARE FIELD DEFINITION Tagged ('$date')

      FIELDS

        Dual(Year($1), YearStart($1)) AS [Year] Tagged ('$axis', '$year'),

        Dual('Q'&Num(Ceil(Num(Month($1))/3)),Num(Ceil(NUM(Month($1))/3),00)) AS [Quarter] Tagged ('$quarter', '$cyclic'),

        Dual(Year($1)&'-Q'&Num(Ceil(Num(Month($1))/3)),QuarterStart($1)) AS [YearQuarter] Tagged ('$yearquarter', '$qualified'),

        Dual('Q'&Num(Ceil(Num(Month($1))/3)),QuarterStart($1)) AS [_YearQuarter] Tagged ('$yearquarter', '$hidden', '$simplified'),

        Month($1) AS [Month] Tagged ('$month', '$cyclic'),

        Dual(Year($1)&'-'&Month($1), monthstart($1)) AS [YearMonth] Tagged ('$axis', '$yearmonth', '$qualified'),

        Dual(Month($1), monthstart($1)) AS [_YearMonth] Tagged ('$axis', '$yearmonth', '$simplified', '$hidden');

       

      DERIVE FIELDS FROM FIELDS [Date] USING [autoCalendar];

       

      RENAME FIELDS

      [Date.autoCalendar.Year] TO Year,

      [Date.autoCalendar.Quarter] TO Quarter,

      [Date.autoCalendar.Month] TO Month,

      [Date.autoCalendar.YearQuarter] TO YearQuarter,

      [Date.autoCalendar.YearMonth] TO YearMonth;