# Fraction of tags with property

**URL:** <https://forum.inductiveautomation.com/t/fraction-of-tags-with-property/111997>\
**Category:** Ignition\
**Tags:** ignition81, scripting\
**Created:** [November 6, 2025, 3:20pm UTC](https://forum.inductiveautomation.com/t/fraction-of-tags-with-property/111997 "2025-11-06T15:20:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leor\_Fishman](https://avatars.discourse-cdn.com/v4/letter/l/e19adc/32.png) [@Leor\_Fishman](https://forum.inductiveautomation.com/u/Leor_Fishman)\
**Post date:** [November 6, 2025, 3:20pm UTC](https://forum.inductiveautomation.com/t/fraction-of-tags-with-property/111997/1 "2025-11-06T15:20:05Z")

</div>

I’ve got X thousand tags with lets say a boolean property. I want to estimate the fraction of those tags with that property.

Obviously there’s the naive option to stack readblocking calls in a script and count that way, but is there some smarter way to do it?

(EDIT: yes, there’s also the option of reading like 200 randomized tags assuming noncorrelated failures. still an ugly stack though)

---

<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:** [November 6, 2025, 3:34pm UTC](https://forum.inductiveautomation.com/t/fraction-of-tags-with-property/111997/2 "2025-11-06T15:34:34Z")

</div>

Have you tried `system.tag.query()`? It is astonishingly fast when you define a HAS property filter.

---

<div class="post-metadata">

**Author:** ![Leor\_Fishman](https://avatars.discourse-cdn.com/v4/letter/l/e19adc/32.png) [@Leor\_Fishman](https://forum.inductiveautomation.com/u/Leor_Fishman)\
**Post date:** [November 6, 2025, 3:39pm UTC](https://forum.inductiveautomation.com/t/fraction-of-tags-with-property/111997/3 "2025-11-06T15:39:13Z")

</div>

is there a system.tag.query.count? or should I just listify and grab len?

---

<div class="post-metadata">

**Author:** ![Nol](https://avatars.discourse-cdn.com/v4/letter/n/8e8cbc/32.png) [@Nol](https://forum.inductiveautomation.com/u/Nol)\
**Post date:** [November 6, 2025, 3:39pm UTC](https://forum.inductiveautomation.com/t/fraction-of-tags-with-property/111997/4 "2025-11-06T15:39:56Z")

</div>

This should work now.

```python
folderPath = "[default]" 

browseFilter = {
    'dataType': 'Boolean',
    'recursive': True
}

browseResults = system.tag.browse(path=folderPath, filter=browseFilter)

tagPaths = [
    str(result['fullPath']) 
    for result in browseResults 
    if isinstance(result, dict) and 'fullPath' in result and result.get('tagType') != 'Folder'
]

if tagPaths:
    qualifiedValues = system.tag.readBlocking(tagPaths)
    trueCount = sum(1 for qv in qualifiedValues if qv.value == True and qv.quality.isGood())

print "Found " + str(trueCount) + " TRUE boolean tags in " + folderPath

```

This is the alternative to use system.tag.query. You could stop and just do do len(pyResults) but then you’d also get tags with bad quality which depends on if you want to include those.

```python
folderPath = "[default]" 
searchPath = folderPath + "/**" 

query_obj = {
    "condition": {
        "properties":{
            "op": "And",
            "conditions": [
                {
                    "prop": "dataType",
                    "comp": "Like",
                    "value": "Boolean"
                },
                {
                    "prop": "value",
                    "comp": "Like",
                    "value": "True"
                },
            ]
        }
    },
    "returnProperties": [
        "value", 
        "quality"
    ]
}
results = system.tag.query(query=query_obj)
pyResults = results.getResults()
trueCount = 0
for tag in pyResults:
    if 'value' in tag and 'quality' in tag:
        isValueTrue = (tag['value'].getValue() == True)
        isQualityGood = tag['quality'].isGood()
        if isValueTrue and isQualityGood:
            trueCount += 1
print "Found " + str(trueCount) + " TRUE boolean tags in " + folderPath

```

---

<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 6, 2025, 3:52pm UTC](https://forum.inductiveautomation.com/t/fraction-of-tags-with-property/111997/5 "2025-11-06T15:52:38Z")

</div>

The `PyWrapper` around the `Results` object returned by `system.tag.query` has some additional methods:

> **[Results.PyWrapper](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.50/com/inductiveautomation/ignition/common/browsing/Results.PyWrapper.html)**
>
> declaration: package: com.inductiveautomation.ignition.common.browsing, class: Results, class: PyWrapper

e.x.  
`getTotalAvailableSize()`

That will probably be faster than a conversion to a list.
