Qlik Community

App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
IMPORTANT security patches for GeoAnalytics Server available to download: READ DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
smithc2005
Contributor III
Contributor III

Redefining InYTD in autoCalendar with a Lookup()

I'm having some trouble redefining inYTD in the predefined autoCalendar. I need to use a combination of business month and day from a separate table to control the flag. The input is a regular date field. I have confirmed that my IF statement works outside of the derived field declarations and I am receiving the expected output. I tried pulling the inYTD field into a straight table and was expecting to see "1" and "0". I got an invalid dimension error, instead. My guess is that this area of code cannot see the tables loaded in the previous section? Or is it the $1 placeholder?

Screenshot 2020-12-15 140412.png

The line in question is:

If (Lookup('BUS_MONTHDAY','GREGORIAN_DATE',Date($1),'CALENDAR') <= Lookup('BUS_MONTHDAY','GREGORIAN_DATE',Today()-1,'CALENDAR'), 1, 0) AS [InYTD] 

 

This is the entire autoCalendar. 

[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 (Lookup('BUS_MONTHDAY','GREGORIAN_DATE',Date($1),'CALENDAR') <= Lookup('BUS_MONTHDAY','GREGORIAN_DATE',Today()-1,'CALENDAR'), 1, 0) AS [InYTD] ,
  Year(Today()-1)-Year($1) AS [YearsAgo] ,
  If (DayNumberOfQuarter($1) <= DayNumberOfQuarter(Today()-1),1,0) AS [InQTD] ,
  4*Year(Today()-1)+Ceil(Month(Today()-1)/3)-4*Year($1)-Ceil(Month($1)/3) AS [QuartersAgo] ,
  Ceil(Month(Today()-1)/3)-Ceil(Month($1)/3) AS [QuarterRelNo] ,
  If(Day($1)<=Day(Today()-1),1,0) AS [InMTD] ,
  12*Year(Today()-1)+Month(Today()-1)-12*Year($1)-Month($1) AS [MonthsAgo] ,
  Month(Today()-1)-Month($1) AS [MonthRelNo] ,
  If(WeekDay($1)<=WeekDay(Today()-1),1,0) AS [InWTD] ,
  (WeekStart(Today()-1)-WeekStart($1))/7 AS [WeeksAgo] ,
  Week(Today()-1)-Week($1) AS [WeekRelNo];

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

 

Labels (2)
1 Reply
smithc2005
Contributor III
Contributor III
Author

If anyone has any advice or if you know the scope of this function it would be highly appreciated!