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

IF ELSEIF THEN syntax in script

Hello

i am trying to write some conditions in the script as follow :


table_calucle :
LOAD code_article,

if (val1>=val2 and val1>=val3, then val1

elseif val2>=val1 and val2>=val3 then val2

elseif val3>=val1 and val3>=val2 then val3

)

as longeur

resident base_article;

 

if someone could help me it would be great

 

thanks

 

2 Solutions

Accepted Solutions
settu_periasamy
Master III
Master III

Hi,

Try this..

 

 

table_calucle :
LOAD
code_article,

if (val1>=val2 and val1>=val3, val1,
     if (val2>=val1 and val2>=val3,val2,
           if(val3>=val1 and val3>=val2,val3))) as longeur

resident base_article;

View solution in original post

Vegar
MVP
MVP

@settu_periasamy gave you the correct syntax using if(), but it looks like you are trying to get the max of a range of values and rangemax() could be a sleeker approach.

Consider replacing your if() with this. 

table_calucle :
LOAD
code_article,

RangeMax(val1,val2,val3) as longeur

resident base_article;

View solution in original post

2 Replies
settu_periasamy
Master III
Master III

Hi,

Try this..

 

 

table_calucle :
LOAD
code_article,

if (val1>=val2 and val1>=val3, val1,
     if (val2>=val1 and val2>=val3,val2,
           if(val3>=val1 and val3>=val2,val3))) as longeur

resident base_article;

Vegar
MVP
MVP

@settu_periasamy gave you the correct syntax using if(), but it looks like you are trying to get the max of a range of values and rangemax() could be a sleeker approach.

Consider replacing your if() with this. 

table_calucle :
LOAD
code_article,

RangeMax(val1,val2,val3) as longeur

resident base_article;