Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to calculate percentage between the range of two values a third value is

Tags:

algorithm

Example:

I'm trying to figure out the calculation for finding the percentage between two values that a third value is.

Example: The range is 46 to 195. The value 46 would 0%, and the value 195 would be 100% of the range. What percentage of this range is the value 65?

rangeMin=46

rangeMax=195

inputValue=65

inputPercentage = ?

like image 264
user45675 Avatar asked Sep 14 '14 16:09

user45675


People also ask

How do you find the percentage of data between two values?

Answer: To find the percentage of a number between two numbers, divide one number with the other and then multiply the result by 100. Let us see an example of finding the percentage of a number between two numbers. Explanation: Let us find the percentage of 30 in 45.

How do you find the percentage difference between three values?

Percent difference formula is obtained by dividing the absolute value of change by the average of the values and then multiplying it with 100.

Can you do percent difference with 3 values?

Percentage difference is useful in manufacturing, design or engineering. Calculating the percentage difference between three numbers requires calculating the percentage differences between paired numbers of the three. Finding this result requires no mathematical knowledge beyond basic arithmetic.

How do you calculate a percentage between a range in Excel?

Enter the formula =C2/B2 in cell D2, and copy it down to as many rows as you need. Click the Percent Style button (Home tab > Number group) to display the resulting decimal fractions as percentages. Remember to increase the number of decimal places if needed, as explained in Percentage tips. Done! : )


2 Answers

Well, I would use the formula

((input - min) * 100) / (max - min) 

For your example it would be

((65 - 46) * 100) / (195 - 46) = 12.75 

Or a little bit longer

range = max - min correctedStartValue = input - min percentage = (correctedStartValue * 100) / range  

If you already have the percentage and you're looking for the "input value" in a given range, then you can use the adjusted formula provided by Dustin in the comments:

value = (percentage * (max - min) / 100) + min 
like image 105
Tom Avatar answered Sep 27 '22 20:09

Tom


I put together this function to calculate it. It also gives the ability to set a mid way 100% point that then goes back down.

Usage

//[] = optional rangePercentage(input, minimum_range, maximum_normal_range, [maximum_upper_range]);  rangePercentage(250, 0, 500); //returns 50 (as in 50%)  rangePercentage(100, 0, 200, 400); //returns 50 rangePercentage(200, 0, 200, 400); //returns 100  rangePercentage(300, 0, 200, 400); //returns 50  

The function

function rangePercentage (input, range_min, range_max, range_2ndMax){      var percentage = ((input - range_min) * 100) / (range_max - range_min);      if (percentage > 100) {          if (typeof range_2ndMax !== 'undefined'){             percentage = ((range_2ndMax - input) * 100) / (range_2ndMax - range_max);             if (percentage < 0) {                 percentage = 0;             }         } else {             percentage = 100;         }      } else if (percentage < 0){         percentage = 0;     }      return percentage; } 
like image 34
Daniel Tonon Avatar answered Sep 27 '22 18:09

Daniel Tonon