This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Calculate value to procent
#1
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 m3h. 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 = ?
Usage of this is i have calculated three Vav. And then i need the sum of these to give me back a procent value to give the regulator.

Found this code on different site. But i think that this is missing somethingSmile 

Code:
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;
}
Reply


Messages In This Thread
Calculate value to procent - by Tokatubs - 10.06.2021, 18:55
RE: Calculate value to procent - by Tokatubs - 11.06.2021, 08:05
RE: Calculate value to procent - by admin - 11.06.2021, 08:11
RE: Calculate value to procent - by Tokatubs - 11.06.2021, 08:27
RE: Calculate value to procent - by tomnord - 07.05.2022, 14:29
RE: Calculate value to procent - by admin - 02.05.2022, 13:08

Forum Jump: