# Need to select active tags based on priority

**URL:** <https://forum.inductiveautomation.com/t/need-to-select-active-tags-based-on-priority/67537>\
**Category:** Ignition\
**Tags:** ignition81, vision\
**Created:** [December 13, 2022, 4:27am UTC](https://forum.inductiveautomation.com/t/need-to-select-active-tags-based-on-priority/67537 "2022-12-13T04:27:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brennan\_Joles](https://avatars.discourse-cdn.com/v4/letter/b/d2c977/32.png) [@Brennan\_Joles](https://forum.inductiveautomation.com/u/Brennan_Joles)\
**Post date:** [December 13, 2022, 4:27am UTC](https://forum.inductiveautomation.com/t/need-to-select-active-tags-based-on-priority/67537/1 "2022-12-13T04:27:24Z")

</div>

I have 45 tags that are all Boolean on/off tags and ranked in priority from 1-45. I need to show the tags that are "ON" or a 1 ranked by priority in a table in vision. What would be the best way to go about this? I have been working with transaction groups, but it almost seems like I would need a separate group for each tag. Could I use a tag event script to write to a database each time it goes active?

---

<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:** [December 13, 2022, 1:33pm UTC](https://forum.inductiveautomation.com/t/need-to-select-active-tags-based-on-priority/67537/2 "2022-12-13T13:33:49Z")

</div>

Do you not need history? Just current value of all? If that's the case, then you don't need a database at all. I would use a single gateway tag change event (with all the tags in its list) that delegates to a function in a project script module, where the most recent value for each tag is cached in a top-level dictionary. The cache would include the tag name and the assigned priority (by custom property, perhaps). Then a timer event would regularly call a function in that same script module to iterate through the dictionary to produce a list of the True values, and then sort by priority, then feed a `DatasetBuilder` to yield something table-friendly, which would then be written to a memory tag.

(:
