Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
NickHoff
Specialist
Specialist

Current Year and Month Indicator

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);

2 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

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


talk is cheap, supply exceeds demand
Anonymous
Not applicable

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,