Hi ,
I need some calculation logic in appain that gives difference of ration numbers example shown below in the screenshot.
Can someone help me to write the logic for this on priority?
Here actual and threshold values are user inputs based on those inputs variance col data to be shown .
Discussion posts and replies are publicly visible
You can create rule inputs for ratio1 and ratio2.
a!localVariables( local!ratio1: "3:1", local!ratio2: "2:1", local!ratio1Array: split(local!ratio1, ":"), local!ratio2Array: split(local!ratio2, ":"), local!lcm: lcm( local!ratio1Array[2], local!ratio2Array[2] ), concat( ( local!ratio1Array[1] * (local!lcm / local!ratio1Array[2]) ) - ( local!ratio2Array[1] * (local!lcm / local!ratio2Array[2]) ), "/", local!lcm ) )
A more refined code for handling when the number is completely divisible.
a!localVariables( local!ratio1: "3:4", local!ratio2: "5:6", local!ratio1Array: split(local!ratio1, ":"), local!ratio2Array: split(local!ratio2, ":"), local!lcm: lcm( local!ratio1Array[2], local!ratio2Array[2] ), local!numerator: ( local!ratio1Array[1] * (local!lcm / local!ratio1Array[2]) ) - ( local!ratio2Array[1] * (local!lcm / local!ratio2Array[2]) ), if( mod(local!numerator, local!lcm) = 0, local!numerator / local!lcm, concat(local!numerator, "/", local!lcm) ) )
Thanks it really helped.
Thanks a lot.
Cool! If this worked, please verify the answers to close this thread.
I have one more question,The question related to grid. is it possible to
possible to?
JS0001 said:rid. is it possible to
is it possible to show entire grid row of data with these cases? if not is it possible to show for variance field(it a textfield)?
You can use the 'backgroundColor' in gridColumn to change the background color.
Something like this.
a!gridField( data: { { actual: 6, convenant: 3, variance: 3 }, { actual: 12, convenant: 6, variance: 6 } }, columns: { a!gridColumn( label: "Actual", value: fv!row.actual, backgroundColor: a!match( value:fv!row.variance, whenTrue: (fv!row.actual*0.5)<(fv!value*0.5), then: "WARN", whenTrue: fv!value<=0, then: "ERROR", whenTrue: fv!value>0, then: "SUCCESS", default: "NONE" ) ), a!gridColumn( label: "convenant", value: fv!row.convenant, backgroundColor: a!match( value:fv!row.variance, whenTrue: (fv!row.actual*0.5)<(fv!value*0.5), then: "WARN", whenTrue: fv!value<=0, then: "ERROR", whenTrue: fv!value>0, then: "SUCCESS", default: "NONE" ) ), a!gridColumn( label: "variance", value: fv!row.variance, backgroundColor: a!match( value:fv!row.variance, whenTrue: (fv!row.actual*0.5)<(fv!value*0.5), then: "WARN", whenTrue: fv!value<=0, then: "ERROR", whenTrue: fv!value>0, then: "SUCCESS", default: "NONE" ) ) } )