Standard Deviation Function
Goal:
Calculate a standard deviation from numbers inserted to Text Inputs in a Document or Bundled Documents.
Instructions:
- Create the Template tag StandardDeviation and attach this tag to all Text Inputs in your Template that should be calculated.
 - Create the Template tag GetStandardDeviationValue and attach this tag to the Text Input in your Template where the sum amount should be inserted.
 - Insert the below-mentioned script to the StandardDeviation tag.
 
Script Example:
| 
 
 
 var finder = LEGITO.documentBuilder.event.createElementFinder();var modeValues = finder.findElementsByTagsAuto(Tags);
 const Results = LEGITO.documentBuilder.getTagsByName("GetStandardDeviationValue");var resultElement = finder.findElementsByTagsAuto(Results)[0];
 let valuesArray = []for(var i in modeValues) {  if(modeValues[i].getValue() !== null) {    valuesArray.push(parseInt(modeValues[i].getValue(), 10));  }  }
 const n = valuesArray.length;const mean = valuesArray.reduce((a,b) => a+b)/n;const s = Math.sqrt(valuesArray.map(x => Math.pow(x-mean,2)).reduce((a,b) => a+b)/n);
 resultElement.setValue(s.toString()); |