Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

klewandowski
New Contributor III

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
reddys310
Honored Contributor II

Re: If date=... in load statement

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