Select to view content in your preferred language

return true if a ${field1} is >= ${field2} or if ${field1} is left unanswered

480
4
Jump to solution
09-15-2023 02:33 AM
j-bromp
New Contributor III

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.

0 Kudos
1 Solution

Accepted Solutions
DougBrowning
MVP Esteemed Contributor

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.

View solution in original post

0 Kudos
4 Replies
j-bromp
New Contributor III

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

0 Kudos
j-bromp
New Contributor III

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

0 Kudos
DougBrowning
MVP Esteemed Contributor

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.

0 Kudos
j-bromp
New Contributor III

thank you so much Doug, that has worked