Select Page

Search Knowledge Base by Keyword

Standard Deviation Function


Calculate a standard deviation from numbers inserted to TextInputs in a Document or Bundled Documents.


  1. Create the Template tag StandardDeviation and attach this tag to all TextInputs in your Template that should be calculated.
  2. Create the Template tag GetStandardDeviationValue and attach this tag to the TextInput in your Template where the sum amount should be inserted.
  3. Insert the below-mentioned script to the StandardDeviation tag.

Script Example:

const Tags = LEGITO.documentBuilder.getTagsByName("StandardDeviation");

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( => Math.pow(x-mean,2)).reduce((a,b) => a+b)/n);