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

Check that values resides between individual limits

Hi guys!

I want to check that a result value resides between the lower and upper limits.
The issue in find is that not all  processes has limits, some has just one limit, not all processes have result values.

I want something like this:

Process_idResult_valueLower_limitUpper_limitValidate
1503060OK
230 80OK
320  -
4120 90NOT OK
50-3 OK
6300  -
7 150300-

 

I have only been able to evaulate when when there is data in result_value, lower_limit and upper_limit with this expression which disregards the rest if there is just one lower, upper limit set or no result value. 
Some help with the handling of white space.


IF(len(trim([UPPER_LIMIT]))=0 or len(trim([LOWER_LIMIT]))=0 or len(trim([RESULT_VALUE]))=0 ,Null(),
IF([RESULT_VALUE] >[UPPER_LIMIT] or [RESULT_NUMBE] <[LOWER_LIMIT], 'NOT OK','OK'))

Hope you guys can help me out!

Labels (1)
1 Solution

Accepted Solutions
dplr-rn
Partner - Master III
Partner - Master III

something like below. 

 

if( len(trim([RESULT_VALUE]))=0 or (len(trim([UPPER_LIMIT]))=0 and len(trim([LOWER_LIMIT]))=0)

    ,Null()  // if result is empty or upper and lower is empty show empty

   ,  if( len(trim([UPPER_LIMIT]))>0 and len(trim([LOWER_LIMIT]))>0

                  , IF([RESULT_VALUE] >[UPPER_LIMIT] or [RESULT_NUMBE] <[LOWER_LIMIT], 'NOT OK','OK') // if both upper and  lower is not empty

                  ,  if( len(trim([UPPER_LIMIT]))>0 

                              , IF([RESULT_VALUE] >[UPPER_LIMIT] , 'NOT OK','OK') // if only upper is not empty

                              , if(  len(trim([LOWER_LIMIT]))>0

                                         ,IF( [RESULT_NUMBE] <[LOWER_LIMIT], 'NOT OK','OK') // if only lower is not empty

                                 )

                      )

       )

)

 

 

View solution in original post

3 Replies
Taoufiq_Zarra

Maye be this :

 

Data:
load *,if(Flag='OK',if(Result_value>=Lower_limit and Result_value<=Upper_limit,'OK',if( Result_value<Lower_limit or Result_value>Upper_limit,'NOT OK'))) as Validate;
load Process_id, Result_value,if(len(trim(Lower_limit))=0 and len(trim(Upper_limit))>0,0,Lower_limit) as Lower_limit,if(len(trim(Lower_limit))>0 and len(trim(Upper_limit))=0,0,Upper_limit) as Upper_limit,if(len(trim(Result_value))=0 or (len(trim(Upper_limit))=0 and len(trim(Lower_limit))=0),'NOK','OK') as Flag;
LOAD * INLINE [
    Process_id, Result_value, Lower_limit, Upper_limit
    1, 50, 30, 60
    2, 30,, 80
    3, 20,,  
    4, 120,, 90
    5, 0, -3,
    6, 300,,  
    7,, 150, 300
];

drop fields Flag;

 

 

output :

Capture.PNG

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
dplr-rn
Partner - Master III
Partner - Master III

something like below. 

 

if( len(trim([RESULT_VALUE]))=0 or (len(trim([UPPER_LIMIT]))=0 and len(trim([LOWER_LIMIT]))=0)

    ,Null()  // if result is empty or upper and lower is empty show empty

   ,  if( len(trim([UPPER_LIMIT]))>0 and len(trim([LOWER_LIMIT]))>0

                  , IF([RESULT_VALUE] >[UPPER_LIMIT] or [RESULT_NUMBE] <[LOWER_LIMIT], 'NOT OK','OK') // if both upper and  lower is not empty

                  ,  if( len(trim([UPPER_LIMIT]))>0 

                              , IF([RESULT_VALUE] >[UPPER_LIMIT] , 'NOT OK','OK') // if only upper is not empty

                              , if(  len(trim([LOWER_LIMIT]))>0

                                         ,IF( [RESULT_NUMBE] <[LOWER_LIMIT], 'NOT OK','OK') // if only lower is not empty

                                 )

                      )

       )

)

 

 

samme_89
Contributor II
Contributor II
Author

Thanks! This works good!