Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
Highlighted
mihai_iov
Contributor II

Error in expression: If takes 2-3 parameters

I'm new to Qlik View, and I'm trying to use nested Ifs in the script to assign to each activity a cycle(defined by Cycle_start and Cycle_stop) but I keep getting the "Error in expression: If takes 2-3 parameters" error, and I didn't managed to find a solution so far.

Script:

LET  Cycle1_start = MakeDate(2017,01,10);

Cycle1_stop= MakeDate(2017,04,29);

Cycle2_start=MakeDate(2017,05,02);

Cycle2_stop=MakeDate(2017,09,11);

Cycle3_start=MakeDate(2017,12,09);

Cycle3_stop=MakeDate(2018,01,08);

LOAD assegnazione as assign_date,

    `cliente_farma_id`,

    codice,

    `user_id`,

    If(Date(assign_date,DD-MM-YY)> $Cycle1_start, 'Ciclo 1',

    If(Date(assign_date,DD-MM-YY) <= $Cycle2_stop and Date(assign_date,DD-MM-YY) >= $Cycle2_start),'Ciclo 2',

    If(Date(assign_date,DD-MM-YY) < $Cycle3_Stop and Date(assign_date,DD-MM-YY) >= $Cycle3_Start,'Ciclo 3))) as Cycle;

SQL SELECT assegnazione,

Help please?

1 Solution

Accepted Solutions
vishsaggi
Esteemed Contributor III

Re: Error in expression: If takes 2-3 parameters

Check this?

LOAD assegnazione as assign_date,

    `cliente_farma_id`,

    codice,

    `user_id`,

    If(Date(assign_date,'DD-MM-YY') >  $(Cycle1_start), 'Ciclo 1',

    If(Date(assign_date,'DD-MM-YY') <= $(Cycle2_stop) and Date(assign_date,'DD-MM-YY') >= $(Cycle2_start),'Ciclo 2',

    If(Date(assign_date,'DD-MM-YY') <  $(Cycle3_Stop) and Date(assign_date,'DD-MM-YY') >= $(Cycle3_Start),'Ciclo 3'))) as Cycle;

SQL SELECT assegnazione,

    `cliente_farma_id`,

    codice,

    `user_id`

FROM alfaintes.attivita;

View solution in original post

2 Replies
big_dreams
Contributor III

Re: Error in expression: If takes 2-3 parameters

Hi,

Date(DateField,'YY-MM-DD')

you are missing single quote

Regards

vishsaggi
Esteemed Contributor III

Re: Error in expression: If takes 2-3 parameters

Check this?

LOAD assegnazione as assign_date,

    `cliente_farma_id`,

    codice,

    `user_id`,

    If(Date(assign_date,'DD-MM-YY') >  $(Cycle1_start), 'Ciclo 1',

    If(Date(assign_date,'DD-MM-YY') <= $(Cycle2_stop) and Date(assign_date,'DD-MM-YY') >= $(Cycle2_start),'Ciclo 2',

    If(Date(assign_date,'DD-MM-YY') <  $(Cycle3_Stop) and Date(assign_date,'DD-MM-YY') >= $(Cycle3_Start),'Ciclo 3'))) as Cycle;

SQL SELECT assegnazione,

    `cliente_farma_id`,

    codice,

    `user_id`

FROM alfaintes.attivita;

View solution in original post