Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

how to create dates comparison in qlikvew:

YTD VS LYTD

QTD VS LQTD

MTD VS LMTD VS PRIOR_YEAR_MTD

WTD VS LWTD VS PRIOR_YEAR_WTD

BELOW IS MY CALENDER SCRIPTY:

//Adding the Calendar
"Calendar":

LOAD
[Date_Dt],

//Standard Date Objects
Day([Date_Dt]) AS DayOfMonth,
WeekDay([Date_Dt]) AS DayName,
Week([Date_Dt]) AS WeekOfYear,
Month([Date_Dt]) AS Month,
Num(Month([Date_Dt])) AS MonthNum,
'Q' &
Ceil(Month([Date_Dt])/3) AS Quarter,
Year([Date_Dt]) AS Year

RESIDENT "FACT_POLICY_SNAP_DLY"
;

3 Replies
arulsettu
Master III
Master III

hi check this

YTQ, QTD, MTD and WTD

kavita25
Partner - Specialist
Partner - Specialist

Hi,

Try the following code and add to your master calendar script:


let vDateToday = num(today());


YTD - LYTD

if(if(Month(date(Floor(Date)))<=3,(Year(date(Floor(Date)))-1)&'-'&(Year(date(Floor(Date)))),(Year(date(Floor(Date))))&'-'&(Year(date(Floor(Date)))+1))=if(Month(((today())))<=3,(Year(((today())))-1)&'-'&(Year(((today())))),(Year(((today()))))&'-'&(Year(((today())))+1)),1,0) as YTD_Flag,

inyeartodate(Date, $(vDateToday), -1,4)* -1  AS LastYTDFlag

MTD- LMTD- PRIOR YEARMTD

inmonth(today(),Date,0)*-1 as MTD_FLAG,

InMonthToDate(Date,$(vDateToday),-1,4)*-1 as LMTD_FLAG,

  InMonthToDate (Date, $(vDateToday),-12,4)*-1 as PREVIOUSYEAR_MTDFlag,

QTD-LQTD

InQuarter(Date,$(vDateToday),-1)* -1 as QTD_FLAG

InQuarter(Date,$(vDateToday),-2)*-1 as LQTD_FLAG

WTD-LWTD-PRIOR YEAR WTD

InWeek(today(),Date,0)*-1 as WTD_FLAG,

  InWeek(Date,$(vDateToday),-1)*-1 as LWTD_FLAG,

inweektodate(Date, addmonths($(vDateToday), -12), 0) * -1 AS PREVIOUSYEAR_WTDFLAG

Regards,

Kavita


Not applicable
Author

Hi Kavita I have tried to implement what you have send but on the report is not populating the values on the fields.