# Tag Query help system.tag.queryTagHistory

**URL:** <https://forum.inductiveautomation.com/t/tag-query-help-system-tag-querytaghistory/103441>\
**Category:** Ignition\
**Created:** [March 10, 2025, 9:55am UTC](https://forum.inductiveautomation.com/t/tag-query-help-system-tag-querytaghistory/103441 "2025-03-10T09:55:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Samueldale](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@Samueldale](https://forum.inductiveautomation.com/u/Samueldale)\
**Post date:** [March 10, 2025, 9:55am UTC](https://forum.inductiveautomation.com/t/tag-query-help-system-tag-querytaghistory/103441/1 "2025-03-10T09:55:03Z")

</div>

Hi all,

Hoping to get some assistance using the system.tag.queryTagHistory function.

I'm trying to query various tags to get a single 24hr minimum value, I have tried using the expression below but can't seem to get a valid expression.

endTime = system.date.now()  
startTime = system.date.addMinutes(endTime, -1440)  
dataSet = system.tag.queryTagHistory(paths=['my tag provider here'], startDate=startTime, endDate=endTime, returnSize=1, aggregationMode="Minimum", returnFormat='Wide')

I have attempted to put then under a binding expression as well as creating a new query tag with the text into the query, neither have yielded a value.

I plan to add these data points into an existing table that has lots of other data points.

Any tips please? Thanks in advance,  
Sam.

---

<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:** [March 10, 2025, 10:04am UTC](https://forum.inductiveautomation.com/t/tag-query-help-system-tag-querytaghistory/103441/2 "2025-03-10T10:04:22Z")

</div>

> `paths=['my tag provider here']`

Are you actually giving a list of tag paths and not just the provider name?  
Are you sure you are logging at least once a day. (What are the tag settings for Max Time Between Samples?

Please see [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831).

---

<div class="post-metadata">

**Author:** ![Samueldale](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@Samueldale](https://forum.inductiveautomation.com/u/Samueldale)\
**Post date:** [March 10, 2025, 10:36am UTC](https://forum.inductiveautomation.com/t/tag-query-help-system-tag-querytaghistory/103441/3 "2025-03-10T10:36:25Z")

</div>

Yeah so here is the actual data I'm putting in; [TagAUBH]GF/AUBH/BRB/BAK00/Supervisor/Data/V3ToV1Voltage

It is logging at a rate of 1 second & I can trend the data.

When I do a simple tag history query it works fine, trouble is that returns the value in a dataset that I can't seem to link to a single data point for my table so I think my solution is to get a query working that will return a single value.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [March 10, 2025, 11:17am UTC](https://forum.inductiveautomation.com/t/tag-query-help-system-tag-querytaghistory/103441/4 "2025-03-10T11:17:19Z")

</div>

> [@Samueldale](#):
>
> I have tried using the expression below but can't seem to get a valid expression.

> [@Samueldale](#):
>
> I have attempted to put then under a binding expression as well as creating a new query tag with the text into the query

This isn't an expression, it's a script. If you are trying to use this as an expression it will not work.

If you're not, be careful with terminology, as the Expression language is not the same a scripting and this can lead to confusion.

```python
endTime = system.date.now()
startTime = system.date.addMinutes(endTime, -1440)
dataSet = system.tag.queryTagHistory(paths=['my tag provider here'], startDate=startTime, endDate=endTime, returnSize=1, aggregationMode="Minimum", returnFormat='Wide')

```

`system.tag.queryTagHistory()` returns a dataset, so to get the value out of the dataset you need to use functions on the dataset to retrieve them. If you are expecting only 1 value to be returned, then that code would look something like this:

```python
dataset.getValueAt(0,1)

```

Or

```python
dataset.getValueAt(0,'[TagAUBH]GF/AUBH/BRB/BAK00/Supervisor/Data/V3ToV1Voltage')

```

You may also want to set `noInterpolation = True` to insure that you are not returning a purely interpolated value.

---

<div class="post-metadata">

**Author:** ![Samueldale](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@Samueldale](https://forum.inductiveautomation.com/u/Samueldale)\
**Post date:** [March 10, 2025, 9:32pm UTC](https://forum.inductiveautomation.com/t/tag-query-help-system-tag-querytaghistory/103441/5 "2025-03-10T21:32:53Z")

</div>

Thanks for the information, it is appreciated.

I think my main issue now is that even when using the tag history binding table it returns as a dataset so if I'm looking for a 24hr minimum I will get a 1x2 dataset (Tstamp & value). What's the easiest way to pick the second column (value) data and move into a integer so it can be linked into my standard table?  
If there was a way to do that under the transform function of the tag history binding section that would be really handy.

 ![dataset1](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/e/3e54e5f82eee8e5d2cd153d76041a5448445e655.png)  
 ![dataset2](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/0/30b234f00a8b26fa4e4eb5b5d1b19321303f30f3.png)

---

<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:** [March 10, 2025, 9:46pm UTC](https://forum.inductiveautomation.com/t/tag-query-help-system-tag-querytaghistory/103441/6 "2025-03-10T21:46:39Z")

</div>

Add Transform | Expression.  
`{value}[0, 1]`

---

<div class="post-metadata">

**Author:** ![Samueldale](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@Samueldale](https://forum.inductiveautomation.com/u/Samueldale)\
**Post date:** [March 10, 2025, 10:11pm UTC](https://forum.inductiveautomation.com/t/tag-query-help-system-tag-querytaghistory/103441/7 "2025-03-10T22:11:24Z")

</div>

> [@Transistor](#):
>
> {value}[0, 1]

Brilliant thanks all & apologies for the basic questions!
