Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Load Script Error

Hi All,

Really new to the forum and qlikview so apologies for how simple this question is and if I have made a stupid error (Highly likely).

I am trying to use an if statement after I have loaded in a data set and this is returning an error of

"Error in expression: ')' expected".

Obviously this indicates my brackets are wrong but I cannot see how!?

Final:
load *,
IF(a=1,                                                                                        'DSM',
IF(b=1,                                                                                        'DSP',
IF(c=1,                                                                                        'WOT',
IF(d=1,                                                                                        'WOP',
IF(0<e<8,                                                                                    'DIC',
IF(e=8 and f='Open',                                                                   'AAT',
IF(e=8 and g='WH',                                                      'WAH',
IF(e=8 and h=0,                                                                          'CHU',
IF(MonthEnd(i)=j,                                                                        'GCT',
IF(k=1,                                                                                          'GCP',
IF(e=0,                                                                                           'UTD',
'Error')))))))))))
as [Life_Cycle]
from [month1];
exit script

Thanks

1 Solution

Accepted Solutions
Peter_Cammaert
Partner - Champion III
Partner - Champion III

Around this part of your nested IF function, there is something weird:

:

IF(d=1, 'WOP',

IF(0<e<8, 'DIC',

IF(e=8 and f='Open', 'AAT',

:

Can you try with this replacement for the middle expression? This one is more like the otthers...

:

IF (e > 0 and e < 8, 'DIC',

:

AFAIK relational operators cannot be combined in a script expression in this way.

Best,

Peter

View solution in original post

5 Replies
MindaugasBacius
Partner - Specialist III
Partner - Specialist III

load *,

  IF(a=1, 'DSM',

  IF(b=1, 'DSP',

  IF(c=1, 'WOT',

  IF(d=1, 'WOP',

  IF(0<e<8, 'DIC',

  IF(e=8 and f='Open', 'AAT',

  IF(e=8 and g='WH', 'WAH',

  IF(e=8 and h=0, 'CHU',

  IF(MonthEnd(i)=j, 'GCT',

  IF(k=1, 'GCP',

  IF(e=0, 'UTD', 'Error'))))))))))) as [Life_Cycle]

from [month1]

;

It seems script have enough paréntesis.

Try to debug the script:

  1. Load script without IF statements.
  2. If it works load with one IF(a = 1 statement.
  3. And than move on to the second if statement IF(b=1
  4. Continue till you get the result to wish.
sunny_talwar

Is this a sample or actual code? Your sample doesn't seem to have any issue, but may be the original code is missing a parenthesis?

Not applicable
Author

Thanks both for response.

I appear to have solved the issue. Although I don't think it was anything to do with a missing bracket....

On line 6 where I have specified, 0<e<8 I believe this needs to be split down to 0<e and e<8. Is this right?

Chanty4u
MVP
MVP

try to load this,

  1. load *, 
  2.   IF(a=1, 'DSM'
  3.   IF(b=1, 'DSP'
  4.   IF(c=1, 'WOT'
  5.   IF(d=1, 'WOP'
  6.   IF(0<e<8, 'DIC'
  7.   IF(e=8 and f='Open', 'AAT'
  8.   IF(e=8 and g='WH', 'WAH'
  9.   IF(e=8 and h=0, 'CHU'
  10.   IF(MonthEnd(i)=j, 'GCT'
  11.   IF(k=1, 'GCP'
  12.   IF(e=0, 'UTD', 'Error'))))))))))) as [Life_Cycle] 
  13. from [month1] ;
Peter_Cammaert
Partner - Champion III
Partner - Champion III

Around this part of your nested IF function, there is something weird:

:

IF(d=1, 'WOP',

IF(0<e<8, 'DIC',

IF(e=8 and f='Open', 'AAT',

:

Can you try with this replacement for the middle expression? This one is more like the otthers...

:

IF (e > 0 and e < 8, 'DIC',

:

AFAIK relational operators cannot be combined in a script expression in this way.

Best,

Peter