# Sum of all rows named \_\_\_\_\_\_\_\_ from a dataset tag?

**URL:** <https://forum.inductiveautomation.com/t/sum-of-all-rows-named-from-a-dataset-tag/65893>\
**Category:** Ignition\
**Created:** [October 31, 2022, 6:34pm UTC](https://forum.inductiveautomation.com/t/sum-of-all-rows-named-from-a-dataset-tag/65893 "2022-10-31T18:34:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![IgnitionNewbie](https://avatars.discourse-cdn.com/v4/letter/i/94ad74/32.png) [@IgnitionNewbie](https://forum.inductiveautomation.com/u/IgnitionNewbie)\
**Post date:** [October 31, 2022, 6:34pm UTC](https://forum.inductiveautomation.com/t/sum-of-all-rows-named-from-a-dataset-tag/65893/1 "2022-10-31T18:34:49Z")

</div>

So im trying to count all the rows of a certain column in a dataset tag with a specific string name  
for example if there is 22 rows in the current dataset  
I am trying to make my 3 new tags show that

10 rows have Name 1  
5 rows have Name 2  
7 rows have Name 3  
so i can put them on a dashboard

I was looking at len but it just counted every row

is there a way to use len based on a condition? or some other method to doing this?

---

<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:** [October 31, 2022, 7:09pm UTC](https://forum.inductiveautomation.com/t/sum-of-all-rows-named-from-a-dataset-tag/65893/2 "2022-10-31T19:09:33Z")

</div>

This is tricky to do from expressions, unless you delegate to scripting via the `runScript` function.

Phil Turmel's [Simulation Aids](https://www.automation-pros.com/modulesales.html) module adds a `view` expression function that would work:  
[https://www.automation-pros.com/simaids/doc/expression.view.html](https://www.automation-pros.com/simaids/doc/expression.view.html)

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [October 31, 2022, 7:24pm UTC](https://forum.inductiveautomation.com/t/sum-of-all-rows-named-from-a-dataset-tag/65893/3 "2022-10-31T19:24:39Z")

</div>

If you were to script it:

```python
from collections import Counter
sampleheaders = ['ndx', 'value']
sampledata = [[1, 'Name 1'],
              [2, 'Name 2'],
              [3, 'Name 3'],
              [4, 'Name 1'],
              [5, 'Name 2'],
              [6, 'Name 3'],
              [7, 'Name 1'],
              [8, 'Name 3'],
              [9, 'Name 1'],
              [10, 'Name 2'],
              [11, 'Name 1'],
              [12, 'Name 3'],
              [13, 'Name 1'],
              [14, 'Name 2'],
              [15, 'Name 1'],
              [16, 'Name 3'],
              [17, 'Name 2'],
              [18, 'Name 1'],
              [19, 'Name 3'],
              [20, 'Name 1'],
              [21, 'Name 3'],
              [22, 'Name 1']
             ]

sampleDS = system.dataset.toDataSet(sampleheaders, sampledata)

col = Counter(sampleDS.getColumnAsList(1))

# Sort by keys
print sorted(col.items())
# Sort by most common values
print col.most_common()

```

Output

```auto
>>> 
[(u'Name 1', 10), (u'Name 2', 5), (u'Name 3', 7)]
[(u'Name 1', 10), (u'Name 3', 7), (u'Name 2', 5)]
>>> 

```
