# New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
Talk to Experts Tuesday, January 26th at 10AM EST: Qlik Sense. REGISTER NOW
cancel
Showing results for
Did you mean:
Partner

## If Statement with dates

Hello dear experts,
I have a field called Fecha as a date, i'm trying evaluate it with a rate of dates depending of the value which evaluating Date field, once i  try to load data the next error comes(Attached image).

if(Fecha<Date(30/01/2015,'DD/MM/YYYY'),
if(PM < PE15,1,0),
if(Fecha>= Date(06/01/2016,'DD/MM/YYYY'),
if(PM < PE16,1,0),
if(Fecha<= Date(10/05/2016,'DD/MM/YYYY'),
if(PM < PE161,1,0),
if(Fecha<= Date(17/11/2017,'DD/MM/YYYY'),
if(PM < PE17,1,0),
if(Fecha<= Date(29/04/2019,'DD/MM/YYYY'),
if(PM < PE,1,0)
)
)
)
)
) as Sub_PE

Thanks for help.

Regards.

1 Solution

Accepted Solutions
Partner

Hello,
I tried this way and works for me, probably someone could use this in a future.

if (Fecha < Date(30/01/2015) and PM < PE15,
1,
IF((Fecha >= Date(30/01/2015)AND Fecha <= Date(06/01/2016))AND PM < PE16,
1,
IF((Fecha >= Date(06/01/2016)AND Fecha <= Date(10/05/2016))AND PM < PE161,
1,
If((Fecha >= Date(10/05/2016)AND Fecha <= Date(17/11/2017))AND PM < PE17,
1,
IF((Fecha >= Date(17/11/2017)AND Fecha <= Date(29/04/2019))AND PM < PE17,
1,0
)
)
)

)
)as Sub_PE

It seems the error comes from the range of dates.

Regards.

4 Replies
Specialist III

I always go

• if  thenEqual
• or if and thenEqual
• not if if if if

if(Fecha<Date(30/01/2015,'DD/MM/YYYY') and PM < PE15,1,0),  'Result1' ,
if(Fecha>= Date(06/01/2016,'DD/MM/YYYY'), 'result2',
if(PM < PE16,1,0),'results3'
etc
)
)
)
)
) as Sub_PE

Partner

Hello Robert,
I tired this way, but the same error comes too

if(Fecha<Date(30/01/2015)
and PM < PE15,1,0),'Result1',
if(Fecha>= Date(06/01/2016)
and PM < PE16,1,0),'Result2',
if(Fecha<= Date(10/05/2016)
and PM < PE161,1,0),'Result3',
if(Fecha<= Date(17/11/2017)
and PM < PE17,1,0),'Result4',
if(Fecha<= Date(29/04/2019)
and PM < PE,1,0),'Result5'as Sub_PE

Regards

Specialist III

Sorry. My previous post may have mislead you

Do you want

if(Fecha<Date(30/01/2015,'DD/MM/YYYY') // I sometimes convert dates to numbers

and
PM < PE15,  //is PE15 a DUAL numerical value?

1,  // result =1

0) //else 0

as Sub_PE,

if so then you need something like

if(Fecha<Date(30/01/2015,'DD/MM/YYYY')

and
PM < PE15,

1,

if(Fecha>= Date(06/01/2016,'DD/MM/YYYY') and
PM < PE16,

1,

0

)) as Sub_PE ,

Partner

Hello,
I tried this way and works for me, probably someone could use this in a future.

if (Fecha < Date(30/01/2015) and PM < PE15,
1,
IF((Fecha >= Date(30/01/2015)AND Fecha <= Date(06/01/2016))AND PM < PE16,
1,
IF((Fecha >= Date(06/01/2016)AND Fecha <= Date(10/05/2016))AND PM < PE161,
1,
If((Fecha >= Date(10/05/2016)AND Fecha <= Date(17/11/2017))AND PM < PE17,
1,
IF((Fecha >= Date(17/11/2017)AND Fecha <= Date(29/04/2019))AND PM < PE17,
1,0
)
)
)

)
)as Sub_PE

It seems the error comes from the range of dates.

Regards.

Tags