I am having trouble with a calculation. I have 10 optional fields named dt_sv_1_kpa up to dt_sv_10_kpa. I wish for a P to be returned if it meets the following conditions, otherwise an F will return:
#sv1 has to be greater than or equal sinmin, if it isn't then the calc should return F
${dt_sv_1_kpa} >= ${kpa_sinmin_dt}
and
#assuming the above condition is met:
#if sv2 is greater than sinmin return P, or if sv2 is left unanswered also return P, the only time this should return F is if sv2 is answered and the value is less than sinmin.
${dt_sv_2_kpa} >= ${kpa_sinmin_dt} or ${dt_sv_2_kpa} = ''
this should then continue all the way through, checking if sv3...sv10 are either unanswered or greater than sinmin. If they are answered but are less than sinmin then an F should be returned.
This would all be one calculation checking through all of the sv's.
I have tried multiple approaches but either get error messages or the result being an F unless all values are entered and above sinmin.
For example I currently have this (shortened to first two):
if(${dt_sv_1_kpa} >= ${kpa_sinmin_dt} and (${dt_sv_2_kpa} >= ${kpa_sinmin_dt} or ${dt_sv_2_kpa} = ''), 'P', 'F' )
but it doesn't return a P unless i put a value into sv2 that is greater than sinmin. The same is true if i change '' to 0.
Solved! Go to Solution.
I have seen this issue with integer before using = "". It used to work years ago but now it is treated differently.
I just tested it and something like if(${testint} = '', "a", "b") does not work.
What does work is if(string-length(${testint}) = 0, "a", "b")
I am not sure I ever figured out why. Give that a shot in a test and see.
so far my only solution to this problem is changing the second variable to a box that automatically populates as 0 until the user enters another number. I then use this calc:
if( ${dt_sv_1_kpa} >= ${kpa_sinmin_dt}, 'P', if( ${dt_sv_2_kpa} >= ${kpa_sinmin_dt}, 'P', if(${dt_sv_2} = 0, 'P', if( ${dt_sv_3_kpa} >= ${kpa_sinmin_dt}, 'P', if(${dt_sv_3} = 0, 'P', if( ${dt_sv_4_kpa} >= ${kpa_sinmin_dt}, 'P', if(${dt_sv_4} = 0, 'P', if( ${dt_sv_5_kpa} >= ${kpa_sinmin_dt}, 'P', if(${dt_sv_5} = 0, 'P', if( ${dt_sv_6_kpa} >= ${kpa_sinmin_dt}, 'P', if(${dt_sv_6} = 0, 'P', if( ${dt_sv_7_kpa} >= ${kpa_sinmin_dt}, 'P', if(${dt_sv_7} = 0, 'P', if( ${dt_sv_8_kpa} >= ${kpa_sinmin_dt}, 'P', if(${dt_sv_8} = 0, 'P', if( ${dt_sv_9_kpa} >= ${kpa_sinmin_dt}, 'P', if(${dt_sv_9} = 0, 'P', if( ${dt_sv_10_kpa} >= ${kpa_sinmin_dt}, 'P', if(${dt_sv_10} = 0, 'P', 'F') ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )
ideally though i don't want 0's populating, so i'm changing the calc for dt_sv_1_kpa to if(${dt_sv_1} = '',round((${dt_sv_1} * ${dt_sv_constant}) , 0) and seeing if that works
This actually doesn't work, it returns a P even if the other values are entered and are less than sinmin which is not what i want... any ideas anyone? Cheers
I have seen this issue with integer before using = "". It used to work years ago but now it is treated differently.
I just tested it and something like if(${testint} = '', "a", "b") does not work.
What does work is if(string-length(${testint}) = 0, "a", "b")
I am not sure I ever figured out why. Give that a shot in a test and see.
thank you so much Doug, that has worked