Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
yipchunyu
Creator
Creator

Limit record in master calendar table

I used below scripts to generate a date dimension table.  however, the latest records is 3/24/2020 and I expected the table should store records up to 202003.  But it now store up to 202012.  How can I fix it?

DROP Table Temp;

MasterCalendar:
Load *,
AutoNumber(Period, 'PeriodID') as [PeriodID],
AutoNumber(Year & Quarter, 'QuarterID') as [QuarterID]
;
LOAD DISTINCT
Year(Temp_Date) * 100 + Month(Temp_Date) as [Period],
Year(Temp_Date) as [Year],
Month(Temp_Date) as [Month],
Date(Temp_Date, 'YYYY-MM') as [Year - Month],
'Q' & Ceil(Month(Temp_Date) / 3) as [Quarter]
;
LOAD DISTINCT
MonthStart($(vMinDate) + IterNo() - 1) as Temp_Date AUTOGENERATE (1)
WHILE $(vMinDate) + IterNo() - 1 <= $(vMaxDate);

 

4 Replies
marcus_sommer

Check $(vMaxDate) because this variable determined until which date the calendar-script is running.

- Marcus

yipchunyu
Creator
Creator
Author

can i simply convert the vMaxDate into a number 'YYYYMM' e.g. 202003?

marcus_sommer

An appropriate formatting + converting is surely possible but I use in such cases simply: year(date) * 100 + month(date)

- Marcus

yipchunyu
Creator
Creator
Author

Found the root cause. My bad, the data files passed from my colleagues are in different date format. 

I changed it as below and the original scripts are working fine.

SET DateFormat='M/D/YYYY';