queryTagHistory for a Boolean Tag CountOn

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:

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:

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?

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

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