# Range aggregation Mode return wrong result

**URL:** <https://forum.inductiveautomation.com/t/range-aggregation-mode-return-wrong-result/27334>\
**Category:** Ignition\
**Created:** [August 10, 2019, 1:50pm UTC](https://forum.inductiveautomation.com/t/range-aggregation-mode-return-wrong-result/27334 "2019-08-10T13:50:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nader.chinichian](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nader.chinichian/32/9261_2.png) [@nader.chinichian](https://forum.inductiveautomation.com/u/nader.chinichian)\
**Post date:** [August 10, 2019, 1:50pm UTC](https://forum.inductiveautomation.com/t/range-aggregation-mode-return-wrong-result/27334/1 "2019-08-10T13:50:22Z")

</div>

Hello  
I history water volume every 10 second and try to get hourly water usage by using Range aggregation mode (Volmax - Volmin). I set the sample size = interval = 1 hour, so the result would be a series of 1 hour record which each one should be Volmax - Volmin in that 1 hour interval. But as it shows in the image result is totally wrong and in some row even 0!!!  
I only get correct result when use Range mode in Tag Calculation query in report for one time period.

 ![Untitled](https://us1.discourse-cdn.com/inductiveautomation/original/2X/e/ece14a7923241fb795bf3313fe0b5d6851de5010.jpeg)

---

<div class="post-metadata">

**Author:** ![nader.chinichian](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nader.chinichian/32/9261_2.png) [@nader.chinichian](https://forum.inductiveautomation.com/u/nader.chinichian)\
**Post date:** [August 12, 2019, 8:27am UTC](https://forum.inductiveautomation.com/t/range-aggregation-mode-return-wrong-result/27334/2 "2019-08-12T08:27:01Z")

</div>

please Any Help

---

<div class="post-metadata">

**Author:** ![Ryan\_Allen](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan_allen/32/47013_2.png) [@Ryan\_Allen](https://forum.inductiveautomation.com/u/Ryan_Allen)\
**Post date:** [April 18, 2023, 2:51pm UTC](https://forum.inductiveautomation.com/t/range-aggregation-mode-return-wrong-result/27334/3 "2023-04-18T14:51:12Z")

</div>

Did you ever figure out a solution to this? I'm running into the same thing... What is Range even supposed to do if it doesn't work as one would expect?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 18, 2023, 3:04pm UTC](https://forum.inductiveautomation.com/t/range-aggregation-mode-return-wrong-result/27334/4 "2023-04-18T15:04:25Z")

</div>

I gave up on history aggregation.

- It doesn't interpolate as one would expect so you don't get values on the hour. That means that the range aggregation (max - min) takes the first and last values that it finds in each hour rather than the "on-the-hour" calculated value.
- It doesn't extrapolate out to the start and end of the date range so it misses the start and end of the period too.

I've raised this in the forum a couple of times but never got a good response from IA. The documentation is weak also so we're left guessing how it's supposed to work.

---

<div class="post-metadata">

**Author:** ![j.israelsen](https://avatars.discourse-cdn.com/v4/letter/j/ad7895/32.png) [@j.israelsen](https://forum.inductiveautomation.com/u/j.israelsen)\
**Post date:** [April 18, 2023, 5:09pm UTC](https://forum.inductiveautomation.com/t/range-aggregation-mode-return-wrong-result/27334/5 "2023-04-18T17:09:38Z")

</div>

Interesting, I had issues with the history aggregation but for different reasons.

Looks like @nader.chinichian mentioned that the aggregation worked if it was for just a single time period. Would looping through and calculating the range (one period at a time) help? If so, perhaps the code mentioned here could be applied to this scenario:

> [@Report - Tag Historian Query Aggregation by Day](https://forum.inductiveautomation.com/t/report-tag-historian-query-aggregation-by-day/69948):
>
> When I'm doing a Tag History Query on a Report I'm having issues dealing with daylight savings as I'm trying to do aggregation over the course of a day (but aggregation intervals can only be configured by hour). Is there anyway to get an aggregation mode by day (instead of hour)? I would hope aggregation by day would then handle the 23 hour day in March and the 25 hour day in November. Or are there other work arounds people have? I would think a lot of people would ha…

Note, this code was used to help resolve issues with daylight savings calculations and did so by looping through day by day (instead of using the history aggregation functions).
