Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
upaliwije
Creator II
Creator II

If condition

Hi

I want to write an if condition to meet following criteria

Range No      Value Range

1                between 10000 to -10000

2                between  10001 to 25000  or -10001 to -25000

3                between  25001 to 50000  or -25001 to -50000

Pls help me to write a script  (if) for following values to fall with given range no

Value     Range No

10000       1

-8000        1

15000        2

-11000       2

-50000       3

1 Solution

Accepted Solutions
Anonymous
Not applicable

... or maybe use the Fabs() function :

Temp :

LOAD * INLINE [

Value

10000

-8000

15000

-11000

-50000

];

Data:

load

  if ( FabsValue <= 10000 , 1 ,

  if ( FabsValue <= 25000 , 2 ,

  if ( FabsValue <= 50000 , 3 , ))) as [Range No] ,

  *

;

load

  Fabs(Value) as FabsValue ,

  Value 

resident Temp

;

drop table Temp ;

View solution in original post

3 Replies
ankit777
Specialist
Specialist

Hi,

Try this script

A:
LOAD * INLINE [
Value
10000
-8000
15000
-11000
-50000
]
;


NoConcatenate
B:
Load Value,
if(Value>=-10000 and Value<= 10000, 1,
if((Value>=10001 and  Value<=25000) or (Value<=-10001 and  Value>=-25000),2,
if((Value>=25001 and  Value<=50000) or (Value<=-25001 and  Value>=-50000),3))) as [Range No]
Resident A;
drop table A;

Anonymous
Not applicable

... or maybe use the Fabs() function :

Temp :

LOAD * INLINE [

Value

10000

-8000

15000

-11000

-50000

];

Data:

load

  if ( FabsValue <= 10000 , 1 ,

  if ( FabsValue <= 25000 , 2 ,

  if ( FabsValue <= 50000 , 3 , ))) as [Range No] ,

  *

;

load

  Fabs(Value) as FabsValue ,

  Value 

resident Temp

;

drop table Temp ;

upaliwije
Creator II
Creator II
Author

Your answer is also correct. But Bills logic is very easy

Thanks