Hi guys, I have a problem with variables.
I'm trying to create a master calendar, this is the code:
- min(OrderDate) as minDate,
- max(OrderDate) as maxDate
- Resident Orders;
- Let varMinDate = Num(Peek('minDate', 0, 'Temp'));
- Let varMaxDate = Num(Peek('maxDate', 0, 'Temp'));
- DROP Table Temp;
- $(varMinDate) + Iterno()-1 As Num,
- Date($(varMinDate) + IterNo() - 1) as TempDate
- AutoGenerate 1 While $(varMinDate) + IterNo() -1 <= $(varMaxDate);
- TempDate AS OrderDate,
- week(TempDate) As Week,
- Year(TempDate) As Year,
- Month(TempDate) As Month,
- Day(TempDate) As Day,
- YeartoDate(TempDate)*-1 as CurYTDFlag,
- YeartoDate(TempDate,-1)*-1 as LastYTDFlag,
- inyear(TempDate, Monthstart($(varMaxDate)),-1) as RC12,
- date(monthstart(TempDate), 'MMM-YYYY') as MonthYear,
- ApplyMap('QuartersMap', month(TempDate), Null()) as Quarter,
- Week(weekstart(TempDate)) & '-' & WeekYear(TempDate) as WeekYear,
- WeekDay(TempDate) as WeekDay
- Resident TempCalendar
- Order By TempDate ASC;
- Drop Table TempCalendar;
The problem is at row 13th, because when I create a variables at rows 7th and 8th, these are <NULL>.
So I tested the code at rows 3th and 4th, and the code doesn't work.
Why I can not extract min and max values from the table?
Let me give you an example.
Thanks for the help