Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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$);
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
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$);
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$);
You were faster
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$);
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
Thank you all! I solved the problem
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.