Forum Discussion

suniba's avatar
suniba
Occasional Visitor
5 years ago

Groovy calculation for pass/fail

Hi,

 

I need help with a calculation rule. I am defining a result field where people have to do data entry in 20 fields. All the data entry is numeric. I have a calculation rule that finds out maximum, minimum and lists all the values in a line.

 

Now I want reuslts to show fail when more than two values are above 80 in all 20fields. How can I do that.

 

I am using following rule for max, min and list:


class CRSAL{
def crystals = [] //Capture all the crystal entry

def addCrystals(List itm){
def crys = itm.flatten()
//add the list item
for(reading in crys){
if(isReal(reading)){crystals.add(reading)}
}
}

Boolean isReal(def Assay){
if(Assay != null && Assay != "" ) { return true }
else { return false }
}

def minCrystal(){
if(crystals.isEmpty()){return "ND"}
else{return crystals.min()}
}

def maxCrystal(){
if(crystals.isEmpty()){return "ND"}
else{return crystals.max()}
}

//Return list of crystals
def lstCrystals(){crystals.sort()}

def reportCrystals(){
if(crystals.isEmpty()){return "ND"}
String report = ""
lstCrystals()
for(itm in crystals){
report = report + " " + itm
}
return report[1..-1]
}
}


CRSAL C1 = new CRSAL()
C1.addCrystals([${Slide 1 (1 of 5);Minimum;*}])
C1.addCrystals([${Slide 1 (1 of 5);Maximum;*}])
C1.addCrystals([${Slide 1 (2 of 5);Minimum;*}])
C1.addCrystals([${Slide 1 (2 of 5);Maximum;*}])
C1.addCrystals([${Slide 1 (3 of 5);Minimum;*}])
C1.addCrystals([${Slide 1 (3 of 5);Maximum;*}])
C1.addCrystals([${Slide 1 (4 of 5);Minimum;*}])
C1.addCrystals([${Slide 1 (4 of 5);Maximum;*}])
C1.addCrystals([${Slide 1 (5 of 5);Minimum;*}])
C1.addCrystals([${Slide 1 (5 of 5);Maximum;*}])

C1.addCrystals([${Slide 2 (1 of 5);Minimum;*}])
C1.addCrystals([${Slide 2 (1 of 5);Maximum;*}])
C1.addCrystals([${Slide 2 (2 of 5);Minimum;*}])
C1.addCrystals([${Slide 2 (2 of 5);Maximum;*}])
C1.addCrystals([${Slide 2 (3 of 5);Minimum;*}])
C1.addCrystals([${Slide 2 (3 of 5);Maximum;*}])
C1.addCrystals([${Slide 2 (4 of 5);Minimum;*}])
C1.addCrystals([${Slide 2 (4 of 5);Maximum;*}])
C1.addCrystals([${Slide 2 (5 of 5);Minimum;*}])
C1.addCrystals([${Slide 2 (5 of 5);Maximum;*}])

${Is Test Performed;Informational} == 'Y'
? C1.reportCrystals()
: ''

 

1 Reply

  • Hello suniba,

     

    The content of your request doesn't look related to Collaborator. Let us know what SmartBear product you use and we will move your post to the appropriate section.