Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
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
Nicole-Smith

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