# queryTagHistory for a Boolean Tag CountOn

**URL:** <https://forum.inductiveautomation.com/t/querytaghistory-for-a-boolean-tag-counton/16919>\
**Category:** Ignition\
**Tags:** ignition79, scripting\
**Created:** [February 7, 2018, 9:31pm UTC](https://forum.inductiveautomation.com/t/querytaghistory-for-a-boolean-tag-counton/16919 "2018-02-07T21:31:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bfuson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bfuson/32/4597_2.png) [@bfuson](https://forum.inductiveautomation.com/u/bfuson)\
**Post date:** [February 7, 2018, 9:31pm UTC](https://forum.inductiveautomation.com/t/querytaghistory-for-a-boolean-tag-counton/16919/1 "2018-02-07T21:31:06Z")

</div>

I have a Boolean OPC Tag that’s tracked by the Historian.

I’d like to get the number of times the tag turned on during a time period.  
Seems like it should be a relatively simple operation with:

```auto
result = system.tag.queryTagHistory(paths=[tagPath], startDate=startDate, endDate=endDate, aggregationModes=['CountOn'], columnNames=['t','total'], noInterpolation=True)

```

Which I would expect to return a single row, with one cell being the integer total number of transitions.  
But instead I get this:

```auto
Row	| t	total	
---------------------------
0	| Wed Feb 07 15:24:06 EST 2018	0	
1	| Wed Feb 07 15:24:16 EST 2018	0	
2	| Wed Feb 07 15:35:16 EST 2018	0	
3	| Wed Feb 07 15:35:26 EST 2018	0	
4	| Wed Feb 07 15:45:17 EST 2018	0	
5	| Wed Feb 07 15:45:27 EST 2018	0	
6	| Wed Feb 07 15:45:37 EST 2018	0	
7	| Wed Feb 07 15:45:47 EST 2018	1	
8	| Wed Feb 07 15:49:47 EST 2018	0	
9	| Wed Feb 07 15:49:57 EST 2018	1	
10	| Wed Feb 07 15:57:27 EST 2018	1	
11	| Wed Feb 07 15:57:37 EST 2018	0	
12	| Wed Feb 07 15:57:47 EST 2018	1	
13	| Wed Feb 07 16:01:37 EST 2018	1	

```

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![accyroy](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/accyroy/32/3386_2.png) [@accyroy](https://forum.inductiveautomation.com/u/accyroy)\
**Post date:** [February 8, 2018, 10:23am UTC](https://forum.inductiveautomation.com/t/querytaghistory-for-a-boolean-tag-counton/16919/2 "2018-02-08T10:23:15Z")

</div>

You just need to add returnSize = 1 into your call.

```auto
result = system.tag.queryTagHistory(paths=[tagPath], startDate=startDate, endDate=endDate, aggregationModes=['CountOn'], returnSize = 1, columnNames=['t','total'], noInterpolation=True)

```
