Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
In my master calendar i'm creating an indicator to determine if the daily load is in the current month, previous month, previous week, and previous 4 weeks.
My indicators are working correctly, but the problem is I only want them for the current year not every year.
// Standard Date Objects
Day(TempDate) AS CalendarDayOfMonth,
WeekDay(TempDate) AS CalendarDayName,
Week(TempDate) AS CalendarWeekOfYear,
Month(TempDate) AS CalendarMonthName,
'Q' & Ceil(Month(TempDate)/3) AS CalendarQuarter,
Year(TempDate) AS CalendarYear,
Num(Month(Today())) AS CurrentMonth,
IF(TempDate <=Today() AND Num(Month(TempDate)) = Num(Month(Today())),1,0) AS CurrentMonthIND,
Num(month(AddMonths(Today(),-1))) AS PreviousMonth,
IF(TempDate <=Today() AND Num(Month(TempDate)) = Num(month(AddMonths(Today(),-1))),1,0) AS PreviousMonthIND,
Date(Num(Date(Today(),'DD/MM/YYYY')-7)) AS PreviousWeek,
if((TempDate <= today() and TempDate >= weekstart(today()-7)),1,0) as PreviousWeekIND,
Date(Num(Date(Today(),'DD/MM/YYYY')-28)) AS Previous4Weeks,
if((TempDate <= today() and TempDate >= weekstart(today()-28)),1,0) as Previous4WeeksIND,
TempDate is derived from a resident load
TempCalendar:
LOAD
$(vDateMin) + RowNo() - 1 AS DateNumber,
Date($(vDateMin) + RowNo() - 1) AS TempDate
AUTOGENERATE 1
WHILE $(vDateMin)+IterNo()-1<= $(vDateMax);
Try the InMonth and InYear functions instead.
InMonth(TempDate, today()) as IsCurrentMonth
InMonth(TempDate, today(), -1) as IsPreviousMonth
InYear(TempDate, today()) as IsCurrentYear
InYear(TempDate, today(), -1) as IsPreviousYear
See if it helps:
Month(Today() AS CurrentMonth, // Month() is dual, no need for num
IF(monthstart(TempDate) = monthstart(today()),1,0) AS CurrentMonthIND,
IF(monthstart(TempDate) = monthstart(today(),-1),1,0) AS PreviousMonthIND,
IF(weekstart(TempDate) = weekstart(today(),-1),1,0) as PreviousWeekIND,