# Help with History binding to query tag

**URL:** <https://forum.inductiveautomation.com/t/help-with-history-binding-to-query-tag/90895>\
**Category:** Ignition\
**Tags:** database, ignition81, perspective\
**Created:** [May 24, 2024, 5:56pm UTC](https://forum.inductiveautomation.com/t/help-with-history-binding-to-query-tag/90895 "2024-05-24T17:56:47Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Smith](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@Michael\_Smith](https://forum.inductiveautomation.com/u/Michael_Smith)\
**Post date:** [May 24, 2024, 5:56pm UTC](https://forum.inductiveautomation.com/t/help-with-history-binding-to-query-tag/90895/1 "2024-05-24T17:56:47Z")

</div>

Hi there  
I have a query tag setup with history enabled. I was then going to bind the data of a table to a tag history binding using the query tag history. Problem is I can only get it to return 4 rows, and the value row is empty. I'm sure I don't have something configured properly, most likely on the query tag, but I can't figure out what.

The query tag returns one row, with 4 columns. The database for this is on a machine. I set the history up to record to the Ignition sql database.

Maybe this isn't the right way? I really don't know where I'm going wrong here, any help is appreciated.

Thanks!

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [May 24, 2024, 6:00pm UTC](https://forum.inductiveautomation.com/t/help-with-history-binding-to-query-tag/90895/2 "2024-05-24T18:00:57Z")

</div>

Can you post pictures of the History tab on the tag and the binding window on the table?  
Sounds like you have the tag configured properly, but are using WIDE format return on the table instead of TALL.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/5/a5a8a1810d2561c22738aaace26ad4d6efa8112f.png)

---

<div class="post-metadata">

**Author:** ![Michael\_Smith](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@Michael\_Smith](https://forum.inductiveautomation.com/u/Michael_Smith)\
**Post date:** [May 24, 2024, 6:05pm UTC](https://forum.inductiveautomation.com/t/help-with-history-binding-to-query-tag/90895/3 "2024-05-24T18:05:15Z")

</div>

Sure! Thanks for the quick reply.  
 ![bindingWindow](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/f/0f60342fd26fe90904f9786b03b32c841d5ede18.png)

 ![tagHistoryTab](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/7/f75d1f97e36ad1409a6d5c0e904df59de116557d.png)

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [May 24, 2024, 6:22pm UTC](https://forum.inductiveautomation.com/t/help-with-history-binding-to-query-tag/90895/4 "2024-05-24T18:22:00Z")

</div>

Everything is correct for the bindings and the dataset is 185 rows.  
you are saying it only shows 4 rows in the table?  
Is it actually displaying?  
Depending on how often that tag changes, you could be looking at one hell of a query against the historian asking for a month AsStored.  
Cut that down to a day or a week and see if it renders?

---

<div class="post-metadata">

**Author:** ![Michael\_Smith](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@Michael\_Smith](https://forum.inductiveautomation.com/u/Michael_Smith)\
**Post date:** [May 24, 2024, 6:25pm UTC](https://forum.inductiveautomation.com/t/help-with-history-binding-to-query-tag/90895/5 "2024-05-24T18:25:38Z")

</div>

I had it set shorter, I set it to a month to make sure I got every row stored just to see if there was something. I set it to a day(which considering I just started this today the return is the same as a month anyway) and this is what I get back.

![return](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/b/cbd91361bc3a71679f278e2dda409ef740c7d344.png)

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [May 24, 2024, 6:29pm UTC](https://forum.inductiveautomation.com/t/help-with-history-binding-to-query-tag/90895/6 "2024-05-24T18:29:52Z")

</div>

What is the tag type?  
And does the tag actually show a value?  
That looks like it is storing a NULL for the value every minute, which is strange in itself as you have it set to Max 5 Minutes between and OnChange for storage.

---

<div class="post-metadata">

**Author:** ![Michael\_Smith](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@Michael\_Smith](https://forum.inductiveautomation.com/u/Michael_Smith)\
**Post date:** [May 24, 2024, 6:34pm UTC](https://forum.inductiveautomation.com/t/help-with-history-binding-to-query-tag/90895/7 "2024-05-24T18:34:45Z")

</div>

It's a query tag. It may or may not show a value depending on if the machine is processing something or not.

I just changed the query to always return something, just to see if that is the problem. Didn't change anything though, but I know for a fact I have a dataset in the query tag now at least.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 24, 2024, 6:56pm UTC](https://forum.inductiveautomation.com/t/help-with-history-binding-to-query-tag/90895/8 "2024-05-24T18:56:23Z")

</div>

> [@Michael\_Smith](#):
>
> The query tag returns one row, with 4 columns

IA's historian doesn't support dataset tags. That you get anything at all is the surprise.

---

<div class="post-metadata">

**Author:** ![Michael\_Smith](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@Michael\_Smith](https://forum.inductiveautomation.com/u/Michael_Smith)\
**Post date:** [May 24, 2024, 7:09pm UTC](https://forum.inductiveautomation.com/t/help-with-history-binding-to-query-tag/90895/9 "2024-05-24T19:09:47Z")

</div>

I was afraid of that. What do you think the solution would be? Write a script to insert the relevant columns into a table on the tag change event? Then do a named query to pull the data?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 24, 2024, 7:14pm UTC](https://forum.inductiveautomation.com/t/help-with-history-binding-to-query-tag/90895/10 "2024-05-24T19:14:43Z")

</div>

What is the original source of the data? Tags? If so, historize them individually. And, perhaps, use tag change events to capture the latest values to keep a scripted dataset up to date.

---

<div class="post-metadata">

**Author:** ![Michael\_Smith](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@Michael\_Smith](https://forum.inductiveautomation.com/u/Michael_Smith)\
**Post date:** [May 24, 2024, 7:21pm UTC](https://forum.inductiveautomation.com/t/help-with-history-binding-to-query-tag/90895/11 "2024-05-24T19:21:00Z")

</div>

The original source is a db. I have a query tag setup to pul the data from a machine(no access to the plc directly), the machine deletes this data every day but we’d like to keep a record of it.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 24, 2024, 7:23pm UTC](https://forum.inductiveautomation.com/t/help-with-history-binding-to-query-tag/90895/12 "2024-05-24T19:23:39Z")

</div>

Set up a table in your own DB that matches the structure. Run a regular timer or scheduled event that copies that data to your DB directly, excluding rows already copied. No tags needed or desired.

---

<div class="post-metadata">

**Author:** ![Michael\_Smith](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@Michael\_Smith](https://forum.inductiveautomation.com/u/Michael_Smith)\
**Post date:** [May 24, 2024, 7:36pm UTC](https://forum.inductiveautomation.com/t/help-with-history-binding-to-query-tag/90895/13 "2024-05-24T19:36:31Z")

</div>

I’ll have to look into how to do that exactly probably a gateway script that does a named query(update)? No, only supports one db connection I believe. Anyway, thanks for the replies and have a great holiday!

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 24, 2024, 8:48pm UTC](https://forum.inductiveautomation.com/t/help-with-history-binding-to-query-tag/90895/14 "2024-05-24T20:48:36Z")

</div>

Separate named queries for retrieval from one and insert to the other.
