Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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
Champion III
Champion III

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
Creator III
Creator III

Hi,

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

you are missing single quote

Regards

vishsaggi
Champion III
Champion III

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;