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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

If date=... in load statement

Hello. I try to write if statement in load part of the script. I have "sale date" in format YYYY-MM-DD hh:mm:ss. I need to add column with value that depends on year.

According to qlik sense help i've written in load that line:

if(Date("sale date",'YYYY')=2011,'CY','LY') as newfield,

but it shows only LY when year is 2011,2010 and in the rest of years there is '-'

so it makes me a little confused what to do with it.

Thanks in advance very much.

1 Reply
reddy-s
Master II
Master II

Hi Kamil,

try this:

if ( year([sale date]) = 2011 ,'CY','LY') as newfield - assuming that the field is recognised as a date field

other wise use this:

if ( year(date#([sale date],'YYYY-MM-DD')) = 2011,'CY','LY' ) as newfield