# Report module Tag History Query Closest Value

**URL:** <https://forum.inductiveautomation.com/t/report-module-tag-history-query-closest-value/93554>\
**Category:** Ignition\
**Tags:** reporting\
**Created:** [July 22, 2024, 6:43pm UTC](https://forum.inductiveautomation.com/t/report-module-tag-history-query-closest-value/93554 "2024-07-22T18:43:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zach\_Larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zach_larson/32/54388_2.png) [@Zach\_Larson](https://forum.inductiveautomation.com/u/Zach_Larson)\
**Post date:** [July 22, 2024, 6:43pm UTC](https://forum.inductiveautomation.com/t/report-module-tag-history-query-closest-value/93554/1 "2024-07-22T18:43:57Z")

</div>

How do I get the value closest to the end of the time range?

Closest value seems to be getting the value closest to the start instead of the end for me.

The historized tag is historized once an hour.

On the report I am looking at the tstamp and the values.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/2/628fa99c2427dd02edcf9f28c7d9b6e0a6ca291e.png)

These are values and timestamps I pull the data source to a table.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/8/a8db6f73b89882001050c741a76c67c18667389f.png)

This is what I am receiving when I specify the specific data.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/8/18f88a87e1c3694ef648b357fca33872f42d3735.png)

`@levels.test01@`

This is why I had expected the last value instead of the first when set to closest value.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/8/2813d4a1ffb879e59b3d1456e1e010d1b3159f95.png)

8.1.39

I am pretty sure that I am setting up the configuration wrong.

---

<div class="post-metadata">

**Author:** ![Zach\_Larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zach_larson/32/54388_2.png) [@Zach\_Larson](https://forum.inductiveautomation.com/u/Zach_Larson)\
**Post date:** [July 22, 2024, 7:03pm UTC](https://forum.inductiveautomation.com/t/report-module-tag-history-query-closest-value/93554/2 "2024-07-22T19:03:53Z")

</div>

Or how do I subquery the tag history query data source so that I can just get the top 1 where tstamp is descending?

* * *

For now I just set the range as the last hour of the actual range so even if it gets the closest value as the early value instead of most recent, at least that is the latest hour of the range. Not ideal, but not sure how to make it fetch the last value.

---

<div class="post-metadata">

**Author:** ![Zach\_Larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zach_larson/32/54388_2.png) [@Zach\_Larson](https://forum.inductiveautomation.com/u/Zach_Larson)\
**Post date:** [September 5, 2024, 6:49pm UTC](https://forum.inductiveautomation.com/t/report-module-tag-history-query-closest-value/93554/3 "2024-09-05T18:49:16Z")

</div>

This ClosestValue option is working terrible.

Is LastValue going to be added as an option?
