getVariation($('dcp.HGCV3/pcl/Pattern', ''), $('dcp.HGCV3/pcl/Lot', ''), $('dcp.HGCV3/pcl/RhoAvgMean', '')); function getVariation(pattern, lot, rhoAvgMean) { var fourPP = 1; var mid4pp = 1; var thin4pp = 1; var low4pp = 1787; var thickness = 1; var high4pp = 7767; var epiPro4pp = 3163; var midThickness = 1; var thinThickness = 1; var lowThickness = 15.46; var highThickness = 20.01; var epiProThickness = 20.28; if (pattern === 'ONEPT.PAT' && lot.toUpperCase().indexOf('EP') > -1) { fourPP = epiPro4pp; thickness = epiProThickness; } else if (pattern === 'ONEPT.PAT' && lot.toUpperCase().indexOf('LO') > -1) { fourPP = low4pp; thickness = lowThickness; } else if (pattern === 'ONEPT.PAT' && lot.toUpperCase().indexOf('MI') > -1) { fourPP = mid4pp; thickness = midThickness; } else if (pattern === 'ONEPT.PAT' && lot.toUpperCase().indexOf('HI') > -1) { fourPP = high4pp; thickness = highThickness; } else if (pattern === 'ONEPT.PAT' && lot.toUpperCase().indexOf('TH') > -1) { fourPP = thin4pp; thickness = thinThickness; } /* =(ABS(C9-H6)/C9)*100 */ var resistivity = thickness * fourPP * 0.0001; var variation = (Math.abs(resistivity - rhoAvgMean) / resistivity) * 100; if (thickness === 1 || fourPP === 1) return null; else return variation; }