5 Replies Latest reply: Dec 12, 2017 6:27 PM by Luis Madriz RSS

    Duplicate derived field

    Balaji SJ

      I am getting the below error, whenever i am loading data through data load editor.

      qlik doubt.PNG

        • Re: Duplicate derived field
          Luis Madriz

          Hi,

           

          You may be using autoCalendar: twice or going through a routine that uses Derive Fields without renaming it.

           

          The only time I've seen this happening is when I created a subroutine to create mastercalendars passing parameters. The second time I passed through it it gave me that error. I corrected by making the name of the field declaration variable vAuto

           

          Something like this:

          // AutoCalendar

            Let vAuto = vDateFieldText & '_Auto';

            [$(vAuto)]:

            Declare Field Definition Tagged ('$date')

            Fields

              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'),

              If (DayNumberOfYear($1) <= DayNumberOfYear(Today()), 1, 0) AS [InYTD] ,

              If (DayNumberOfYear($1,7) <= DayNumberOfYear(Today(),7), 1, 0) AS [InFYTD] ,

              If(Day($1)<=Day(Today()),1,0) AS [InMTD] ,

              Year(Today())-Year($1) AS [YearsAgo] ,

              12*Year(Today())+Month(Today())-12*Year($1)-Month($1) AS [MonthsAgo] ,

              Month(Today())-Month($1) AS [MonthRelNo];

            Derive Fields from Fields $(vDateFieldName) Using [$(vAuto)];

          • Re: Duplicate derived field
            Digvijay Singh

            Can you share your calendar script snippet, looks like something is wrong related to it.

             

            Thanks,

              • Re: Duplicate derived field
                Balaji SJ

                [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'),

                  Dual('W'&Num(Week($1),00), Num(Week($1),00)) AS [Week] Tagged ('$weeknumber', '$cyclic'),

                  Date(Floor($1)) AS [Date] Tagged ('$axis', '$date', '$qualified'),

                  Date(Floor($1), 'D') AS [_Date] Tagged ('$axis', '$date', '$hidden', '$simplified'),

                  If (DayNumberOfYear($1) <= DayNumberOfYear(Today()), 1, 0) AS [InYTD] ,

                  Year(Today())-Year($1) AS [YearsAgo] ,

                  If (DayNumberOfQuarter($1) <= DayNumberOfQuarter(Today()),1,0) AS [InQTD] ,

                  4*Year(Today())+Ceil(Month(Today())/3)-4*Year($1)-Ceil(Month($1)/3) AS [QuartersAgo] ,

                  Ceil(Month(Today())/3)-Ceil(Month($1)/3) AS [QuarterRelNo] ,

                  If(Day($1)<=Day(Today()),1,0) AS [InMTD] ,

                  12*Year(Today())+Month(Today())-12*Year($1)-Month($1) AS [MonthsAgo] ,

                  Month(Today())-Month($1) AS [MonthRelNo] ,

                  If(WeekDay($1)<=WeekDay(Today()),1,0) AS [InWTD] ,

                  (WeekStart(Today())-WeekStart($1))/7 AS [WeeksAgo] ,

                  Week(Today())-Week($1) AS [WeekRelNo] ;

                 

                 

                DERIVE FIELDS FROM FIELDS [eff date], [exp date] USING [autoCalendar] ;