GreenInfo-Network / seattle-building-dashboard

Energy benchmarking for Seattle
https://greeninfo-network.github.io/seattle-building-dashboard/
ISC License
1 stars 0 forks source link

Calculation Error in energy use trends % change? #16

Closed danrademacher closed 2 years ago

danrademacher commented 2 years ago

Pulled out of #9

I think they are calculating percent change wrong here:

image

    const previousValue = yearData[0].val;
    const selectedValue = yearData[1].val;
    return ((selectedValue - previousValue) / selectedValue) * 100;

They are dividing the difference by the current value, not the initial value

The formula should be: ( current_value - initial_value ) / initial_value * 100

Simple real-life example from last comment

(3-2)/3 = 33% vs (3-2)/2=50%

┆Issue is synchronized with this Asana task

danrademacher commented 2 years ago

@seattle-benchmarking can you take a lok at this issue and see if you agree we should change this calculation? It would change some outputs even for the same data compared to the current produciton deploy, so we wanted to check with you before making a change.

seattle-benchmarking commented 2 years ago

@danrademacher yes you're right. it should be using the initial value as the denominator. Thanks for catching this.