Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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_id | Result_value | Lower_limit | Upper_limit | Validate |
1 | 50 | 30 | 60 | OK |
2 | 30 | 80 | OK | |
3 | 20 | - | ||
4 | 120 | 90 | NOT OK | |
5 | 0 | -3 | OK | |
6 | 300 | - | ||
7 | 150 | 300 | - |
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!
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
)
)
)
)
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 :
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
)
)
)
)
Thanks! This works good!