# Ongoing count by matching tag values

**URL:** <https://forum.inductiveautomation.com/t/ongoing-count-by-matching-tag-values/90498>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [May 16, 2024, 2:03pm UTC](https://forum.inductiveautomation.com/t/ongoing-count-by-matching-tag-values/90498 "2024-05-16T14:03:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rfolkes](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@rfolkes](https://forum.inductiveautomation.com/u/rfolkes)\
**Post date:** [May 16, 2024, 2:03pm UTC](https://forum.inductiveautomation.com/t/ongoing-count-by-matching-tag-values/90498/1 "2024-05-16T14:03:21Z")

</div>

There is a lot more to this tag structure but for simplicity just going to include basic structure that is relevant to question

TagUDT  
Parameter.Zones = 1,2 \*List of integer values so could be just a single integer or 1,2,3,4 or 3,5 etc  
Status = True/False

the number of instances of this tag could be anywhere from 5 -1000+

What I am looking for is to end up with a set of other tags (Zone X status count) with value = the number of UDT instances that have zone X within parameters.zone and status = True

While parameters.zone is not fixed permanent it will rarely change however status on any can change at any time and I want the count to be as close to a real time / fast update as possible. Of note the udt instances are located in different folders independent of the paramters.zone values and folder structure can not be changed

Looking for general ideas on how you would accomplish this or examples if you have done something similar in the past

---

<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 16, 2024, 2:45pm UTC](https://forum.inductiveautomation.com/t/ongoing-count-by-matching-tag-values/90498/2 "2024-05-16T14:45:57Z")

</div>

I would use the techniques in this topic:

> [@Java concurrent queue for tag change scripts](https://forum.inductiveautomation.com/t/java-concurrent-queue-for-tag-change-scripts/82044/38):
>
> Okay. Draft for your edification: [queueUtil.py](https://www.automation-pros.com/ignition/queueUtil.py) Includes Google docstrings. Utterly untested. grimacing Maybe later. Edit: docstring typos fixed and ambiguities addressed. Heh: if you delete all comments, docstrings, and blank lines, it is 29 lines of code.

and this topic:

> [@Modbus Slave/Server to Generate Read Only Tags](https://forum.inductiveautomation.com/t/modbus-slave-server-to-generate-read-only-tags/87583/21):
>
> I've create a generic "Modbus Publish" script that eliminates the need for a second set of tags. I've publicly posted it here: [https://www.automation-pros.com/ignition/modbusPublish.py](https://www.automation-pros.com/ignition/modbusPublish.py) It requires the "Queue Utility" script posted here: [https://www.automation-pros.com/ignition/queueUtil.py](https://www.automation-pros.com/ignition/queueUtil.py) and described over here: Both scripts rely on my Integration Toolkit's globalVarMap() script function, but you can rework that (not quite 1:1) to use system.util.getGlobals() if you must. (Not recomme…

.. to report the status changes to a project library script for cross referencing.

In the timer processing script, cache the zones per status tag. Force update the cached zones on any `initialChange`.

For each zone, maintain a `set()` of true status tag paths. Each queued event would loop through the tag's zones adding or removing from the set.

Within the event, track which zones you've touched with a temporary set.

After processing all queued events for that tick of the timer, loop through the zones that were touched and build a list of zone tags to update. The values are the lengths of the zones' sets.
