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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

If in script

Hi,

I want to use IF in my script to determine a field "JoursLitige" which depends on others fields so I did like this but I have an error "Error in expression: ')' expected"

LOAD  ID,

     DateFacture ,

     Today() - DateFacture as DépassementLitige,

    

     if ((DépassementLitige <= 30),'1',

     if ((31 <= DépassementLitige <= 60), '2',

     if ((61 <= DépassementLitige <= 90),'3', '4'))) as JoursLitige

FROM

[..\..\file.xls] (biff, embedded labels, table is A$);

8 Replies
crusader_
Partner - Specialist
Partner - Specialist

Hi,

You're not allowed use DépassementLitige inside same table LOAD.

To solve problem just use this one:

LOAD  ID,

     DateFacture ,

     Today() - DateFacture as DépassementLitige,

   

     if (((Today() - DateFacture) <= 30),'1',

     if (((Today() - DateFacture) <= 60), '2',

     if (((Today() - DateFacture) <= 90),'3', '4'))) as JoursLitige

FROM

[..\..\file.xls] (biff, embedded labels, table is A$);


Hope this helps.

Andrei

anbu1984
Master III
Master III

Load *,

     if ((DépassementLitige <= 30),'1',

     if ((DépassementLitige <= 60), '2',

     if ((DépassementLitige <= 90),'3', '4'))) as JoursLitige;

LOAD  ID,

     DateFacture ,

     Today() - DateFacture as DépassementLitige   

FROM

[..\..\file.xls] (biff, embedded labels, table is A$);

simondachstr
Specialist III
Specialist III

Use a preceding load:

LOAD  *,

     if ((DépassementLitige <= 30),'1',

     if ((31 <= DépassementLitige <= 60), '2',

     if ((61 <= DépassementLitige <= 90),'3', '4'))) as JoursLitige

     ;

LOAD  ID,

     DateFacture ,

     Today() - DateFacture as DépassementLitige,   

FROM

[..\..\file.xls] (biff, embedded labels, table is A$);

simondachstr
Specialist III
Specialist III

You were faster

Not applicable
Author

hello,

you have missed two ')' of if function,and one more thing you have to 'AND' operation between two expression ,

your code should be like this

LOAD  ID,

     DateFacture ,

     Today() - DateFacture as DépassementLitige,

      if (((Today() - DateFacture) <= 30),'1',if ((31 <= (Today() - DateFacture) and  (Today() - DateFacture) <= 60), '2',if ((61 <= (Today() - DateFacture) and (Today() - DateFacture)<= 90),'3', '4'))))) as JoursLitige

FROM

[..\..\file.xls] (biff, embedded labels, table is A$);

crusader_
Partner - Specialist
Partner - Specialist

31 <= (Today() - DateFacture)

(61 <= (Today() - DateFacture)

are excess conditions, because if your number not less or euqal 30 - it's definitely more or equal than 31

Andrei


Not applicable
Author

Thank you all! I solved the problem

jagan
Partner - Champion III
Partner - Champion III

Hi,

Try like this

LOAD

*,

if (DépassementLitige <= 30,'1',

     if (DépassementLitige <= 60, '2',

     if (DépassementLitige <= 90),'3', '4'))) as JoursLitige;

LOAD  ID,

     DateFacture ,

     Today() - DateFacture as DépassementLitige

FROM

[..\..\file.xls] (biff, embedded labels, table is A$);


Hope this helps you.


Regards,

Jagan.