Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I would like to increase the actual years in my Calendar by two years. The actual first and last years in the date field of the Order table, on which the current Calendar is based, are 2010 and 2021 respectively. The script would change these years to 2012 and 2023 respectively. I have tried AddYears in the Calendar script, but this does not work.
Thanks in advance for any help!
Here is my Calendar script (note that I have commented attempts below to make this work using the AddYears function):
DateRange:
LOAD
min(Date) as MinDate,
max(Date) as MaxDate
// AddYears(min(Date, 2) as MinDate,---> did not work
// AddYears(max(Date, 2)) as MaxDate,---> did not work
// Min(AddYears(Date, 2)) as MinDate,---> did not work
// Max(AddYears(Date, 2)) as MaxDate,---> did not work
Resident POS;
LET vMinDate = Peek('MinDate',0,'DateRange');
LET vMaxDate = Peek('MaxDate',0,'DateRange');
TempCalDate:
LOAD
date($(vMinDate) + RowNo() -1) as CalDate
AutoGenerate $(vMaxDate) - $(vMinDate) + 1;
Calendar:
LOAD
CalDate as Date,
day(CalDate) as Day,
WeekDay(CalDate) as WeekDay,
Year(CalDate) as Year,
Month(CalDate) as Month,
week(CalDate) as Week,
'Q' & Ceil(month(CalDate)/3) as Quarter,
4*Year(Today())+Ceil(Month(Today())/3)-4*Year(1)-Ceil(Month(1)/3) AS [QuartersAgo],
date(monthstart(CalDate), 'MMM-YYYY') as MonthYear,
date(QuarterStart(CalDate), 'QQ-YYYY') as QuarterYear
Resident TempCalDate
order by CalDate asc;
drop Tables DateRange, TempCalDate;
LOAD
min(Date) as MinDate,
max(Date) as MaxDate,
AddYears(min(Date), 2) as MinDate,
AddYears(max(Date), 2) as MaxDate
resident table
Resident POS;
thanks, Anat
This script results in the following error. Any other thoughts?
"The following error occurred:
field names should be unique in the load script.
thanks, Anat
I think this will work, but I tried another approach and it worked.
I commented the Date field in the POS (i.e., Date table source) and replaced it with "AddYears(Date,2) as Date".
That did the trick.
Thanks again for your help!