# "Show percent change" on version 10.3

**URL:** <https://community.grafana.com/t/show-percent-change-on-version-10-3/115478>\
**Category:** Dashboards\
**Created:** [February 26, 2024, 8:29pm UTC](https://community.grafana.com/t/show-percent-change-on-version-10-3/115478 "2024-02-26T20:29:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![eveuca](https://avatars.discourse-cdn.com/v4/letter/e/54ee81/32.png) [@eveuca](https://community.grafana.com/u/eveuca)\
**Post date:** [February 26, 2024, 8:29pm UTC](https://community.grafana.com/t/show-percent-change-on-version-10-3/115478/1 "2024-02-26T20:29:10Z")

</div>

- What Grafana version and what operating system are you using?  
10.3.1 running on kubernetes

- **What** are you trying to achieve?  
I need to explain to my boss how this value is calculated.

- **How** are you trying to achieve it?  
I need to explain to my boss how this value is calculated.

- What happened?  
We have enabled “Show percent change” but we don’t understand how this math works.

- Screenshots:  

I tried to read the code, but I’m not good at programming: [Stat: Add Percent Change Option by drew08t · Pull Request #78250 · grafana/grafana · GitHub](https://github.com/grafana/grafana/pull/78250/files)

Can someone help me to conclude on how this 28.3% is calculated?  
I can think of the following options:

a. 28.3% more users on the last 1 hour (based on Step)  
b. 28.3% more users based on the same date 7 days ago (based on query option relative time)  
c. 28.3% more users based on the last data point (we have one datapoint every 10 minutes)

“c” does not makes a lot of sense, as my app does not behave as such.

---

<div class="post-metadata">

**Author:** ![davidallen5](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/davidallen5/32/32092_2.png) [@davidallen5](https://community.grafana.com/u/davidallen5)\
**Post date:** [February 26, 2024, 8:52pm UTC](https://community.grafana.com/t/show-percent-change-on-version-10-3/115478/2 "2024-02-26T20:52:50Z")

</div>

I had a quick look at the code, and I think the relevant code bit is right here:

The way the calculation works is as follows:

- The field gets reduced through the use of a special field reducer in the transformations package, called “[diffperc](https://github.com/grafana/grafana/blob/dbbaa1967ff4786f4e37b133b22a3e88f43ded05/packages/grafana-data/src/transformations/fieldReducer.ts#L408)”
- The way _that_ calculation works is that it reuses the “diff” calculation, and then divides by the first non-null field value.
- The way “diff” works is that it subtracts the first non-null from the last non-null value. ([See reference here](https://github.com/grafana/grafana/blob/dbbaa1967ff4786f4e37b133b22a3e88f43ded05/packages/grafana-data/src/transformations/fieldReducer.ts#L404))

So over a 7-day period as in your screenshot, I think what’s going on here is that the first value is subtracted by the last value, then divided by the “starting value” (first non-null field value) and you get the result like that. Example, let’s say your data is:

```auto
null, null, 1, 2, 3, 4, 5, null, 5, 4, null

```

Diff would be 4 - 1, and diffperc would be (4-1) / 1 = 300%

---

<div class="post-metadata">

**Author:** ![ajonthibault](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@ajonthibault](https://community.grafana.com/u/ajonthibault)\
**Post date:** [November 29, 2024, 10:25am UTC](https://community.grafana.com/t/show-percent-change-on-version-10-3/115478/3 "2024-11-29T10:25:16Z")

</div>

Isn’t the % wrong with negative values ?  
First value : -0.0491  
Last value : 0.129

- -362 %  
But we obviously increase

---

<div class="post-metadata">

**Author:** ![pooh](https://avatars.discourse-cdn.com/v4/letter/p/f05b48/32.png) [@pooh](https://community.grafana.com/u/pooh)\
**Post date:** [November 29, 2024, 10:38am UTC](https://community.grafana.com/t/show-percent-change-on-version-10-3/115478/4 "2024-11-29T10:38:49Z")

</div>

If you start with (positive) 2 and end up with 8, that’s a 400% increase.

If you start with -2 and end up with 8, the factor is -400%.

You have to multiply a negative number by a negative number to get a positive  
result.

Antony.

---

<div class="post-metadata">

**Author:** ![ajonthibault](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@ajonthibault](https://community.grafana.com/u/ajonthibault)\
**Post date:** [November 29, 2024, 10:56am UTC](https://community.grafana.com/t/show-percent-change-on-version-10-3/115478/5 "2024-11-29T10:56:39Z")

</div>

yes so it’s not really working for mixed pos / meg values
