# Easy custom formulas on fitness charts

**URL:** <https://forum.intervals.icu/t/easy-custom-formulas-on-fitness-charts/123646>\
**Category:** New Features\
**Created:** [2 March 2026 14:49 UTC](https://forum.intervals.icu/t/easy-custom-formulas-on-fitness-charts/123646 "2026-03-02T14:49:53Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![david](https://forum.intervals.icu/user_avatar/forum.intervals.icu/david/32/30189_2.png) [@david](https://forum.intervals.icu/u/david)\
**Post date:** [2 March 2026 14:49 UTC](https://forum.intervals.icu/t/easy-custom-formulas-on-fitness-charts/123646/1 "2026-03-02T14:49:53Z")

</div>

We (tx @ryandev ) have added support for custom formulas on custom charts on the /fitness page. These are simple math expressions and (hopefully!) easy for non-software developers to write. Here is a BMI chart:

 ![Screenshot 2026-03-04 at 15.19.29](https://forum.intervals.icu/uploads/default/original/3X/4/d/4d4d8550e0d6c6a86e6b8103f2278d6a082f2a2b.png)

Choose “Custom Charts” → “Add” → “Chart” to add a new custom chart. Then do “Add Plot” and search for “Formula”:

 ![Screenshot 2026-03-04 at 15.15.16](https://forum.intervals.icu/uploads/default/original/3X/0/a/0a65d56e82f6d38505da81f6501a986439012531.png)

Click the little pencil under “Formula” on the table to exit the expression. Choose “Add Plot” to insert the expression for weight into the formula:

 ![Screenshot 2026-03-04 at 15.16.09](https://forum.intervals.icu/uploads/default/original/3X/0/2/025f4243f495578a40bc230fbb7e26067d3b043c.png)

The athlete is available as a variable for fields like ‘height’ so you can complete the BMI formula:

 ![Screenshot 2026-03-07 at 14.12.25](https://forum.intervals.icu/uploads/default/original/3X/0/4/047280240456c06faab6a689c05c43ed8d9de2eb.png)

The pre days field specifies how many days of data should be included before the start of the date range. This is useful for formulas that compute moving averages and so on. Pre days will be at least this number and maybe more depending on other plots and charts.

There many built in functions, some of which are on the “Function” drop down. For a complete list please see this [list of mathjs functions](https://mathjs.org/docs/reference/functions.html).

If you select a plot with argument (e.g. the duration for “Best Power”) then these are prompted for and inserted into the expression:

 ![Screenshot 2026-03-04 at 15.37.26](https://forum.intervals.icu/uploads/default/original/3X/5/f/5f851547d9acebf2332e02bd20d40e54f7352ee9.png)

 ![Screenshot 2026-03-04 at 15.37.38](https://forum.intervals.icu/uploads/default/original/3X/b/8/b8825d278a39da4a62d9ad4525dde795051bed16.png)

 ![Screenshot 2026-03-04 at 15.37.52](https://forum.intervals.icu/uploads/default/original/3X/2/1/21134b420ad510965235047353319c49c8bba590.png)

## Advanced Usage

The expressions are [evaluated by mathjs](https://mathjs.org/index.html) and most functionality is available in Intervals.icu.

The formula is evaluated once for each day in the date range. You can assign values to variables and these carry over from one day to the next (0 for the first day). You can create multi line expressions where the value of the expression is the value from the last line.

Here is the exponentially weighted moving average for fitness (CTL):

```
f = exp(-1 / 42)
v = v * f + (fitness_load ?? 0) * (1 - f)

```

Note the use of the `??` operator to convert null or undefined fitness\_load (no training on that day) into zero.

 ![Screenshot 2026-03-07 at 14.22.00](https://forum.intervals.icu/uploads/default/original/3X/9/2/92d50e723ad5e1cca75f5b129d452c4611920f29.png)

I used the dot dot dot menu for the formula plot to put it on the same axis as fitness:

 ![Screenshot 2026-03-07 at 14.33.46](https://forum.intervals.icu/uploads/default/original/3X/4/e/4ea620132d9ffdcb0b567bd55c8f416a295979e7.png)

To get this to match the built in “Fitness” plot you need to change pre days to fetch more data before the start of the date range.

 ![Screenshot 2026-03-07 at 14.25.39](https://forum.intervals.icu/uploads/default/original/3X/d/b/dbcea95480ddc66c6d9304da24b2b16150c1bee5.png)  
 ![Screenshot 2026-03-07 at 14.25.59](https://forum.intervals.icu/uploads/default/original/3X/7/9/79bdb5c69d804811a31d0f19f35baa4dc90da333.png)

---

<div class="post-metadata">

**Author:** ![GiGoTmd](https://forum.intervals.icu/user_avatar/forum.intervals.icu/gigotmd/32/84741_2.png) [@GiGoTmd](https://forum.intervals.icu/u/GiGoTmd)\
**Post date:** [4 March 2026 16:29 UTC](https://forum.intervals.icu/t/easy-custom-formulas-on-fitness-charts/123646/2 "2026-03-04T16:29:40Z")

</div>

Very nice addition!

---

<div class="post-metadata">

**Author:** ![FredSPast](https://forum.intervals.icu/user_avatar/forum.intervals.icu/fredspast/32/54765_2.png) [@FredSPast](https://forum.intervals.icu/u/FredSPast)\
**Post date:** [4 March 2026 18:52 UTC](https://forum.intervals.icu/t/easy-custom-formulas-on-fitness-charts/123646/3 "2026-03-04T18:52:09Z")

</div>

This is fantastic for us non-programmers, thank you!

---

<div class="post-metadata">

**Author:** ![GiGoTmd](https://forum.intervals.icu/user_avatar/forum.intervals.icu/gigotmd/32/84741_2.png) [@GiGoTmd](https://forum.intervals.icu/u/GiGoTmd)\
**Post date:** [4 March 2026 20:39 UTC](https://forum.intervals.icu/t/easy-custom-formulas-on-fitness-charts/123646/4 "2026-03-04T20:39:45Z")

</div>

Trying to use the formula to calculate “percentage time spent in zone 1+2”  
but I must be doing something wrong because I get values way above 100%

I’m using “time\_in\_hr\_s1/(time\_in\_hr\_s1+time\_in\_hr\_s2+time\_in\_hr\_s3)” as the formula

 ![Screenshot_20260304_213723_Chrome](https://forum.intervals.icu/uploads/default/original/3X/f/3/f3acc80adb3726ac8453770105badf88ee92fb1e.jpeg)

---

<div class="post-metadata">

**Author:** ![pepe](https://forum.intervals.icu/user_avatar/forum.intervals.icu/pepe/32/36539_2.png) [@pepe](https://forum.intervals.icu/u/pepe)\
**Post date:** [4 March 2026 21:03 UTC](https://forum.intervals.icu/t/easy-custom-formulas-on-fitness-charts/123646/5 "2026-03-04T21:03:59Z")

</div>

> [@GiGoTmd](#):
>
> time\_in\_hr\_s1/(time\_in\_hr\_s1+time\_in\_hr\_s2+time\_in\_hr\_s3)

Your formula works well for me.

 ![imagem](https://forum.intervals.icu/uploads/default/original/3X/d/3/d38e7f769ad696d507516c57de626be31e62dc55.png)

---

<div class="post-metadata">

**Author:** ![miguell](https://forum.intervals.icu/letter_avatar_proxy/v4/letter/m/85f322/32.png) [@miguell](https://forum.intervals.icu/u/miguell)\
**Post date:** [4 March 2026 21:13 UTC](https://forum.intervals.icu/t/easy-custom-formulas-on-fitness-charts/123646/6 "2026-03-04T21:13:50Z")

</div>

Awesome, thank you.

---

<div class="post-metadata">

**Author:** ![GiGoTmd](https://forum.intervals.icu/user_avatar/forum.intervals.icu/gigotmd/32/84741_2.png) [@GiGoTmd](https://forum.intervals.icu/u/GiGoTmd)\
**Post date:** [5 March 2026 07:59 UTC](https://forum.intervals.icu/t/easy-custom-formulas-on-fitness-charts/123646/7 "2026-03-05T07:59:38Z")

</div>

> [@GiGoTmd](#):
>
> time\_in\_hr\_s1/(time\_in\_hr\_s1+time\_in\_hr\_s2+time\_in\_hr\_s3)

strange, for me the formula does not work, the results of the formula are way to high, way above 100%.

Is seems the devission is the problem “time\_in\_hr\_s1+time\_in\_hr\_s2+time\_in\_hr\_s3” works and time\_in\_hr\_s1 works but deviding the two messes things up.

 ![Screenshot_20260305_090506_Chrome](https://forum.intervals.icu/uploads/default/original/3X/8/1/81c9d50020151e663c1d73ac3a8a453545505a03.jpeg)

EDIT:

The formula works is charts but not in the new Totals-table.  
When you Group by Day the results are correct, but when you group by Week, Month or Year things go bad.  
The Day-results get summed when grouping, instead of calculating the totals for the week(group) and then deviding.

 ![Screenshot_20260305_091845_Chrome](https://forum.intervals.icu/uploads/default/original/3X/9/8/984d7e37dba643fe9cb8efa37f8f12a344e1f70f.jpeg)

 ![Screenshot_20260305_091938_Chrome](https://forum.intervals.icu/uploads/default/original/3X/2/d/2dd9951293248853f282859cb34190f320c21911.jpeg)

---

<div class="post-metadata">

**Author:** ![sprouty76](https://forum.intervals.icu/user_avatar/forum.intervals.icu/sprouty76/32/41040_2.png) [@sprouty76](https://forum.intervals.icu/u/sprouty76)\
**Post date:** [5 March 2026 13:35 UTC](https://forum.intervals.icu/t/easy-custom-formulas-on-fitness-charts/123646/8 "2026-03-05T13:35:40Z")

</div>

Am I correct in thinking that there’s no way for the formula to use data from previous days (apart from variables created specifically for that)?

---

<div class="post-metadata">

**Author:** ![david](https://forum.intervals.icu/user_avatar/forum.intervals.icu/david/32/30189_2.png) [@david](https://forum.intervals.icu/u/david)\
**Post date:** [5 March 2026 14:02 UTC](https://forum.intervals.icu/t/easy-custom-formulas-on-fitness-charts/123646/9 "2026-03-05T14:02:21Z")

</div>

Yes. I suppose we could add a `prev` binding and make the expressions a bit more concise?

---

<div class="post-metadata">

**Author:** ![sprouty76](https://forum.intervals.icu/user_avatar/forum.intervals.icu/sprouty76/32/41040_2.png) [@sprouty76](https://forum.intervals.icu/u/sprouty76)\
**Post date:** [5 March 2026 14:05 UTC](https://forum.intervals.icu/t/easy-custom-formulas-on-fitness-charts/123646/10 "2026-03-05T14:05:05Z")

</div>

Well, I meant more things like averages over arbitrary periods of time, rather than just the previous day itself - but that would probably massively complicate what’s meant to be straightforward.

---

<div class="post-metadata">

**Author:** ![david](https://forum.intervals.icu/user_avatar/forum.intervals.icu/david/32/30189_2.png) [@david](https://forum.intervals.icu/u/david)\
**Post date:** [5 March 2026 17:45 UTC](https://forum.intervals.icu/t/easy-custom-formulas-on-fitness-charts/123646/11 "2026-03-05T17:45:54Z")

</div>

If your moving average is for the field you are calculating you can add that on after like for normal plots.

---

<div class="post-metadata">

**Author:** ![sprouty76](https://forum.intervals.icu/user_avatar/forum.intervals.icu/sprouty76/32/41040_2.png) [@sprouty76](https://forum.intervals.icu/u/sprouty76)\
**Post date:** [5 March 2026 17:47 UTC](https://forum.intervals.icu/t/easy-custom-formulas-on-fitness-charts/123646/12 "2026-03-05T17:47:17Z")

</div>

No, it would be used in a calculation. Not a problem, just thought I’d ask.

---

<div class="post-metadata">

**Author:** ![david](https://forum.intervals.icu/user_avatar/forum.intervals.icu/david/32/30189_2.png) [@david](https://forum.intervals.icu/u/david)\
**Post date:** [5 March 2026 17:54 UTC](https://forum.intervals.icu/t/easy-custom-formulas-on-fitness-charts/123646/13 "2026-03-05T17:54:26Z")

</div>

Mathjs supports arrays and there is a mean function so you could probably implement a moving average quite easily. I haven’t had much time to play with this and figure out what is possible yet.

- [Matrices](https://mathjs.org/docs/datatypes/matrices.html)
- [Mean](https://mathjs.org/docs/reference/functions/mean.html)

We probably need to add a “pre days” option to start n days before the date range for moving average type calculations.

---

<div class="post-metadata">

**Author:** ![david](https://forum.intervals.icu/user_avatar/forum.intervals.icu/david/32/30189_2.png) [@david](https://forum.intervals.icu/u/david)\
**Post date:** [7 March 2026 12:37 UTC](https://forum.intervals.icu/t/easy-custom-formulas-on-fitness-charts/123646/14 "2026-03-07T12:37:32Z")

</div>

We have added pre days and an example calculating CTL to the original post.

 ![Screenshot 2026-03-07 at 14.37.10](https://forum.intervals.icu/uploads/default/original/3X/3/7/37b579759e109ca49a1c93b8e092dfd5c5ecbe7c.png)

---

<div class="post-metadata">

**Author:** ![jspira](https://forum.intervals.icu/user_avatar/forum.intervals.icu/jspira/32/47730_2.png) [@jspira](https://forum.intervals.icu/u/jspira)\
**Post date:** [11 March 2026 12:23 UTC](https://forum.intervals.icu/t/easy-custom-formulas-on-fitness-charts/123646/15 "2026-03-11T12:23:17Z")

</div>

Thanks @david and @ryandev for this feature. It’s brilliant. It’s yet another reason for me to recommend Intervals to friends.

Could you please check whether a bug has crept in? I had been playing around at creating different formulas when the feature first dropped. Approx 3 days ago, I found that when I select a field to add it to a formula (Add Plot in the Express dialog), the selected field does not transfer to the Expression.

 ![Screenshot 2026-03-11 081126](https://forum.intervals.icu/uploads/default/original/3X/3/8/3827b929257323f37fd505b139624f89e42565fe.png)  
 ![Screenshot 2026-03-11 081109](https://forum.intervals.icu/uploads/default/original/3X/5/6/563e0d5525de8d6f577224e9dee821e6b9b9ce68.png)

Browser: Chrome 146.0.7680.72

Thanks in advance to taking a look at this.

---

<div class="post-metadata">

**Author:** ![ryandev](https://forum.intervals.icu/user_avatar/forum.intervals.icu/ryandev/32/75654_2.png) [@ryandev](https://forum.intervals.icu/u/ryandev)\
**Post date:** [11 March 2026 13:12 UTC](https://forum.intervals.icu/t/easy-custom-formulas-on-fitness-charts/123646/16 "2026-03-11T13:12:06Z")

</div>

Thank you for the bug report, the fix will be live soon.

---

<div class="post-metadata">

**Author:** ![MichaMue](https://forum.intervals.icu/user_avatar/forum.intervals.icu/michamue/32/35769_2.png) [@MichaMue](https://forum.intervals.icu/u/MichaMue)\
**Post date:** [23 March 2026 20:55 UTC](https://forum.intervals.icu/t/easy-custom-formulas-on-fitness-charts/123646/17 "2026-03-23T20:55:25Z")

</div>

I would like to create a bar chart (or column chart) to show my daily calorie balance. I simply subtract the calories consumed from my total daily calorie allowance. This works perfectly with point and line charts, but for some reason, the bar chart isn’t displaying negative values?

 ![20260323_intervals_bar_chart_no_neg_values](https://forum.intervals.icu/uploads/default/original/3X/6/3/6371912569b7f02f8380d965cd3569ff5c68a3cb.png)

Thanks in advance for the support!

---

<div class="post-metadata">

**Author:** ![ohmax](https://forum.intervals.icu/user_avatar/forum.intervals.icu/ohmax/32/50303_2.png) [@ohmax](https://forum.intervals.icu/u/ohmax)\
**Post date:** [24 March 2026 06:42 UTC](https://forum.intervals.icu/t/easy-custom-formulas-on-fitness-charts/123646/18 "2026-03-24T06:42:33Z")

</div>

Interesting so except using this new formula feature, there was no other way to chart time spent in HR Zones on the platform?

---

<div class="post-metadata">

**Author:** ![MichaMue](https://forum.intervals.icu/user_avatar/forum.intervals.icu/michamue/32/35769_2.png) [@MichaMue](https://forum.intervals.icu/u/MichaMue)\
**Post date:** [24 March 2026 07:50 UTC](https://forum.intervals.icu/t/easy-custom-formulas-on-fitness-charts/123646/19 "2026-03-24T07:50:31Z")

</div>

There is a way …

 ![2026-03-24_intervals_time in zones](https://forum.intervals.icu/uploads/default/original/3X/5/9/59b042d2a62771dff97903042b4790344a60e08a.png)

Michael

---

<div class="post-metadata">

**Author:** ![ivan\_Suero\_Gonzalez](https://forum.intervals.icu/letter_avatar_proxy/v4/letter/i/73ab20/32.png) [@ivan\_Suero\_Gonzalez](https://forum.intervals.icu/u/ivan_Suero_Gonzalez)\
**Post date:** [23 April 2026 09:51 UTC](https://forum.intervals.icu/t/easy-custom-formulas-on-fitness-charts/123646/20 "2026-04-23T09:51:15Z")

</div>

Good morning, I’m trying to find a formula to estimate the “more realistic” load for my strength training. Here it is:

“Weight Training” ? (rpe \* (elapsed\_time \* 60) \* 0.12) : load

The problem is that it includes the time spent on all my daily activities, and the data isn’t accurate, as I only need it to consider my strength training sessions.

What options do you see to solve this?

Thank you very much.

[Next page](https://forum.intervals.icu/t/easy-custom-formulas-on-fitness-charts/123646.md?page=2)
