Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Javascript to calculate the average

Guest
Jan 27, 2016 Jan 27, 2016

Hi Experts,

I have a requirement as follows.The below sheet shows the value from 1.a to 9.a

When I select High in 1.a then the value should be 1.4 and when selecting 2.a as medium then it should multiply the value of SD 2 (15* 1.a weight), similarly for other questions too.

1.a

Reason1

High

NA

NA

High - Weight = 1.4
Medium - Weight = 1.2
Low - Weight = 1

2.a

Reason2

Major

100

100

Major (100) - System will be unavailable for 1 or more business days during operating hours
Medium  (15*1.a Weight) -  System will be unavailable or experience intermittent availability for 4 hours or more during operating periods
Minor (5*1.a Weight) - System will be unavailable or experience intermittent availability between 1 - 4 hours during operating periods
No impact (0) - No Impact or System will be unavailable or experience intermittent availability for less than 0.5 hours during operating periods or outside operating periods

Note: Response score is calculated using the formula Response Score * Weight of SD1 Question

3.a

Reason3

SBU

15

20

Enterprise (20) - Weight = 1.4;  More than 50% of population is affected, 2 or more SBU's are affected, 2 or more locations
SBU (15) - Weight = 1.2; 1 SBU is affected, 5 or more departments, More than 25% of the population
Department (10) - Weight = 1.1; Less than 5 Departments
Users (0) – Weight = 1; Not applicable or  Less than 10 Users

4.a

Reason4

Several Features

6

21

Extensive (15 * 3.a Weight) - Changes on the user interface including change in screen flow/major functionalities. Training required.
Several Features (5 * 3.a Weight) - No user interface changes but new functionalities may be introduced. Training required.
Look & Feel (2 * 3.a Weight) - Cosmetic changes but the same actions/screen flow. Training not applicable.
Minor (0) - Change not visible to the end users. Training is not applicable.

Note: Response score is calculated using the formula Response Score * Weight of 3.a Question

5.a

Reason5

Yes Major

21

21

Yes Major (15 * 1.a Weight) - Degradation >= 20%
Yes Minor (5 * 1.a Weight) - Degradation < 20%
No (0) - No Degradation

Note: Response score is calculated using the formula Response Score * Weight of SD1 Question

6.a

Reason6

Yes Minor

2

5

Yes Major (5) - Multiple documents
Yes Minor (2) - One document
No (0) - No updates required

7.a

reason7

No

0

12

Yes Major (15) - Multiple HP Applications
Yes Minor (5) - One HP Application
No (0) - No updates required

8.a

Reason8

Yes

0

100

Yes (0) - Low
No (100) - High

9.a

Reason 9

No

0

100

Yes (100) - High
No (0) - Low

Based on this questions the impact should be calculated. If the score of above questions are then the Risk field should be High if value is between 80-100 .

Change Category

Major

Scoring Reference

Impact

Range

High

80-100++

Medium

50-79

Low

0-49

IT Area

Max Rating

Total Rating

Impact Rating

Team 1

379

144

High

A New field to be created which captures the risk value.

TOPICS
Acrobat SDK and JavaScript , Windows
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 30, 2016 Jan 30, 2016

Do you have a specific question, or do you expect us to write your entire script for you?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 31, 2016 Jan 31, 2016

Hi

I need the logic of the script.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 01, 2016 Feb 01, 2016
LATEST

You place the value of the fields to be used in the average into an array. Next filter out unwanted data element if needed, like empty elements. Now sum the elements of the array. Divide the sum of the elements in the array by the number of items in the array and assign the result to the field for the result;

A function like will compute the average of the values in an array of values.

function average(data){

   // computes the average of the values within an array;

   var sum = data.reduce(function(sum, value){

     return sum + value;

   }, 0);

   var avg = sum / data.length;

   return avg;

   } // end function average;

The above is the JavaScript syntax for the computation. I assume you understand how to get field values and add the values to an arraty. If needed you can use the array filter method or prototype to remove unwanted data elements.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 31, 2016 Jan 31, 2016

You need to create a custom calculation to sum the values and count the number of items to be used in the calculation, not all "averages" use the total number of entries, and divide the sum by the number items used or needed for computing the average as long as that number is not zero

There a number of JavaScript sites that provide user written functions for calculating various statistics.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines