# Better way to display tag history?

**URL:** <https://forum.inductiveautomation.com/t/better-way-to-display-tag-history/53071>\
**Category:** Ignition\
**Created:** [November 15, 2021, 1:57pm UTC](https://forum.inductiveautomation.com/t/better-way-to-display-tag-history/53071 "2021-11-15T13:57:37Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![SKA](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ska/32/29528_2.png) [@SKA](https://forum.inductiveautomation.com/u/SKA)\
**Post date:** [November 15, 2021, 1:57pm UTC](https://forum.inductiveautomation.com/t/better-way-to-display-tag-history/53071/1 "2021-11-15T13:57:37Z")

</div>

Hi, i have enabled tag history for some string values, that are in a struct, so 7 copies of allvalue names exists.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/1/011aefbd2ab3a10fa31ec63b9a89dda9a9b59dac.png)

But this way, its hard to get a good over view of the data.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/7/b7320d18732d95d6d9f60d3a0907a3799e34c1e0.png)

The default/“OK” value is “0000” and im tryhing to catch the fault code of the modbus communication with 7 pressure sensors on my desk, but randomly i get some error on a random device.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [November 15, 2021, 4:29pm UTC](https://forum.inductiveautomation.com/t/better-way-to-display-tag-history/53071/2 "2021-11-15T16:29:45Z")

</div>

If that’s a power table, I would look into the `configureCell` extension function.

If the cell’s contents are `0000`, I would consider not displaying _anything_ - but for any other value, you could give the particular cell a vibrant background color to immediately grab attention.

---

<div class="post-metadata">

**Author:** ![SKA](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ska/32/29528_2.png) [@SKA](https://forum.inductiveautomation.com/u/SKA)\
**Post date:** [November 16, 2021, 7:47am UTC](https://forum.inductiveautomation.com/t/better-way-to-display-tag-history/53071/3 "2021-11-16T07:47:53Z")

</div>

if is. and i got some script that semi-works

```auto
	if (textValue == "0000" and Value < 99999 and value > 0 and trim(textValue) <> ""):
		return {'background': 'white', 'foreground': 'black'}
	else:
		return {'background': 'purple', 'foreground': 'white'}

```

But this still marks “empty” cells, and date/time cells (t\_stamp), cant really figure out whats really wrong, but the if-statement seems a bit over kill for this.

---

<div class="post-metadata">

**Author:** ![SKA](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ska/32/29528_2.png) [@SKA](https://forum.inductiveautomation.com/u/SKA)\
**Post date:** [November 16, 2021, 8:39am UTC](https://forum.inductiveautomation.com/t/better-way-to-display-tag-history/53071/4 "2021-11-16T08:39:41Z")

</div>

Also, how can i sort this on the column t\_stamp so i get the newest first?  
Now its displayed as entered in the tag historian database (=oldest first)

---

<div class="post-metadata">

**Author:** ![SKA](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ska/32/29528_2.png) [@SKA](https://forum.inductiveautomation.com/u/SKA)\
**Post date:** [November 16, 2021, 9:09am UTC](https://forum.inductiveautomation.com/t/better-way-to-display-tag-history/53071/5 "2021-11-16T09:09:50Z")

</div>

Yesterday i changed it up and made 7 power tables.  
Still not so much viewable, and this is just after a trial end and just started up the hmi, cpu spikes and so far only one of 7 shows any data

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

---

<div class="post-metadata">

**Author:** ![SKA](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ska/32/29528_2.png) [@SKA](https://forum.inductiveautomation.com/u/SKA)\
**Post date:** [November 16, 2021, 12:05pm UTC](https://forum.inductiveautomation.com/t/better-way-to-display-tag-history/53071/6 "2021-11-16T12:05:20Z")

</div>

And some wierd thing happened.  
The mysql database contains 23997 rows of tag data.  
Bith the designer and vision client now is suuuuuuuuper slow and consume alot of cpu.  
Saving the project can take 30 minutes (tried rebooting several times)

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

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/1/d171e5c4164e8e33d38efdceb7e5854274487fc2.png)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [November 16, 2021, 3:23pm UTC](https://forum.inductiveautomation.com/t/better-way-to-display-tag-history/53071/7 "2021-11-16T15:23:28Z")

</div>

> [@SKA](#):
>
> The mysql database contains 23997 rows of tag data.  
> Bith the designer and vision client now is suuuuuuuuper slow and consume alot of cpu.  
> Saving the project can take 30 minutes (tried rebooting several times)

Did you check the 'Retain Rows' checkbox on the binding that populates the data on this table?  
Does your script still look just like what you originally posted, or have you made further changes?

Generally slow behavior means there's either something holding up the event dispatch thread (which is where `configureCell` has to run, so you must make sure to avoid 'slow' operations like tag reads or DB operations) or there's an extremely large dataset being saved into the Vision window (which unchecking 'Retain Rows' avoids).

---

<div class="post-metadata">

**Author:** ![SKA](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ska/32/29528_2.png) [@SKA](https://forum.inductiveautomation.com/u/SKA)\
**Post date:** [November 17, 2021, 7:06am UTC](https://forum.inductiveautomation.com/t/better-way-to-display-tag-history/53071/8 "2021-11-17T07:06:41Z")

</div>

Nope, never checked that box.

The sql is different now:

```auto
SELECT sqlt_data_1_2021_11.t_stamp, sqlt_data_1_2021_11.stringvalue, sensor.tagText AS SensorText, ecodes.errortext FROM sqlt_data_1_2021_11
inner join sensorid Sensor ON sensor.tagID = sqlt_data_1_2021_11.tagid 
inner join ecodes ON sqlt_data_1_2021_11.stringvalue = ecodes.errorcode
WHERE stringvalue != "0000"
;

```

This filters out 99.99999% of the data since most records are “0000” and only leaves me with errorcodes, that the joins translates to a sensor and errorcode with text from the help file matching the ID’s

EDIT: Now i got to find a way to convert the t\_stamp to actual date/time, the from\_timestamp in mysql doesnt work for example.

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [November 17, 2021, 1:59pm UTC](https://forum.inductiveautomation.com/t/better-way-to-display-tag-history/53071/9 "2021-11-17T13:59:40Z")

</div>

Curious what your plan is when we rollover into December. If you are using tag history, then to me it's easier to get the data via script,  
[https://docs.inductiveautomation.com/display/DOC81/system.tag.queryTagHistory](https://docs.inductiveautomation.com/display/DOC81/system.tag.queryTagHistory)

For t\_stamp, see this post,

> [@F\*\*\*\*\*\* timestamps/dates](https://forum.inductiveautomation.com/t/f-timestamps-dates/2593):
>
> How can I convert the Date datatype in to seconds since epoch?

```auto
FROM_UNIXTIME(t_stamp/ 1000)

```

---

<div class="post-metadata">

**Author:** ![SKA](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ska/32/29528_2.png) [@SKA](https://forum.inductiveautomation.com/u/SKA)\
**Post date:** [November 17, 2021, 2:02pm UTC](https://forum.inductiveautomation.com/t/better-way-to-display-tag-history/53071/10 "2021-11-17T14:02:12Z")

</div>

> [@jlandwerlen](#):
>
> Curious what your plan is when we rollover into December

Its not for production, its only to look for problems on my desk plc, so i caneasilly just change with table i want to look at for the day, trying to find a reason behind the random modbus time outs im getting, and thought to use the tag history in educational purpose.

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [November 17, 2021, 2:15pm UTC](https://forum.inductiveautomation.com/t/better-way-to-display-tag-history/53071/11 "2021-11-17T14:15:45Z")

</div>

You can’t use the PLC for traps?
