Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

Can anyone explain how this CURYTD and LastYTD flags work?

Hi all,

Can anyone please explain how the following lines of code work to get the CURYTD and LastYTD flags in the script?

INYEARTODATE(TempDate, $(vToday), 0) * -1 AS CurYTDFlag,
INYEARTODATE(TempDate, $(vToday), -1) * -1 AS LastYTDFlag

I am having real trouble understanding the 0 and -1 functions as part of the expression so I am getting really confused.

Any illustrations would be good.

1 Reply

Re: Can anyone explain how this CURYTD and LastYTD flags work?

INYEARTODATE(TempDate, $(vToday), 0) is checking if your date (TempDate) is in the same year (0) as today (vToday).  If it's true it will return -1 and false will return 0.  I'm guessing that's why they are multiplying by -1 in order to work with positive numbers (0 and 1).


Likewise, INYEARTODATE(TempDate, $(vToday), -1) is checking if your date (TempDate) is in today's (vToday) year - 1 (last year).

Community Browser