# Reporting Module - Tag Historian Query - Max t\_stamp

**URL:** <https://forum.inductiveautomation.com/t/reporting-module-tag-historian-query-max-t-stamp/12748>\
**Category:** Ignition\
**Created:** [March 2, 2017, 8:15pm UTC](https://forum.inductiveautomation.com/t/reporting-module-tag-historian-query-max-t-stamp/12748 "2017-03-02T20:15:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nate.Olson](https://avatars.discourse-cdn.com/v4/letter/n/35a633/32.png) [@Nate.Olson](https://forum.inductiveautomation.com/u/Nate.Olson)\
**Post date:** [March 2, 2017, 8:15pm UTC](https://forum.inductiveautomation.com/t/reporting-module-tag-historian-query-max-t-stamp/12748/1 "2017-03-02T20:15:47Z")

</div>

I’m working on a report that displays a daily max and when it happened. I’m using a Tag Historian Query and can successfully show the max value, but I’m unsure how get the associated t\_stamp. In the preview mode I see the t\_stamp and value in the xml so I know it’s there I just can’t get that row out of the xml dataset result.

Thanks for any advice

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [March 2, 2017, 9:04pm UTC](https://forum.inductiveautomation.com/t/reporting-module-tag-historian-query-max-t-stamp/12748/2 "2017-03-02T21:04:04Z")

</div>

Hmmm… I don’t have any problems accessing the t\_stamp. In the Design panel, on the left, under Key Browers, expand Datasources, expand the name of your tag history query, and t\_stamp should be one of the columns available to you.

If that’s not the case, you might need to contact support and do a screen share with them so they can see what’s going on.

---

<div class="post-metadata">

**Author:** ![Nate.Olson](https://avatars.discourse-cdn.com/v4/letter/n/35a633/32.png) [@Nate.Olson](https://forum.inductiveautomation.com/u/Nate.Olson)\
**Post date:** [March 2, 2017, 9:54pm UTC](https://forum.inductiveautomation.com/t/reporting-module-tag-historian-query-max-t-stamp/12748/3 "2017-03-02T21:54:20Z")

</div>

Kathy,

Thank you for the reply. Yes I confirm the t\_stamp column, but I am specifically looking for the t\_stamp when the max value occurred. I can’t quite figure out how to filter the dataset. I’m just looking for the max value and when it happened. Basically get t\_stamp when value = max(value)

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [March 2, 2017, 11:26pm UTC](https://forum.inductiveautomation.com/t/reporting-module-tag-historian-query-max-t-stamp/12748/4 "2017-03-02T23:26:04Z")

</div>

Ah, I see what you mean now. Unfortunately, although the tag calculation query gives you the max value, it doesn’t give you when that happened.

I see two ways you could do it. One is to query the tag history database yourself. That could get ugly if you need to query across partitions, but it’s doable.

The other way would be to do a tag history query, then have a script datasource below it to loop through the tag history results and look for the timestamp of the max value. [The docs](https://docs.inductiveautomation.com:8443/display/DOC79/Scripting+in+Reporting) have an example of how to loop through a previous datasource with a script datasource.

---

<div class="post-metadata">

**Author:** ![Nate.Olson](https://avatars.discourse-cdn.com/v4/letter/n/35a633/32.png) [@Nate.Olson](https://forum.inductiveautomation.com/u/Nate.Olson)\
**Post date:** [March 3, 2017, 12:08am UTC](https://forum.inductiveautomation.com/t/reporting-module-tag-historian-query-max-t-stamp/12748/5 "2017-03-03T00:08:21Z")

</div>

Understood. Thank you for options.
