# Filter Data based on value for Count Query

**URL:** <http://discussions.gridprotectionalliance.org/t/filter-data-based-on-value-for-count-query/1425>\
**Category:** openHistorian\
**Created:** [June 26, 2025, 2:17pm UTC](http://discussions.gridprotectionalliance.org/t/filter-data-based-on-value-for-count-query/1425 "2025-06-26T14:17:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jarurlaj](http://discussions.gridprotectionalliance.org/letter_avatar_proxy/v4/letter/j/9dc877/32.png) [@jarurlaj](http://discussions.gridprotectionalliance.org/u/jarurlaj)\
**Post date:** [June 26, 2025, 2:17pm UTC](http://discussions.gridprotectionalliance.org/t/filter-data-based-on-value-for-count-query/1425/1 "2025-06-26T14:17:39Z")

</div>

Hi I’m building a stat panel in Grafana to track the count of low gas trips. This is a binary point and I’m wondering if there is a way to filter the value of the point such that I only count when the value is 1 (i.e. the point trips). My base query below:

> Count(FILTER ActiveMeasurements WHERE PointTag = ‘LOW\_GAS’)

---

<div class="post-metadata">

**Author:** ![clackner-gpa](http://discussions.gridprotectionalliance.org/user_avatar/discussions.gridprotectionalliance.org/clackner-gpa/32/556_2.png) [@clackner-gpa](http://discussions.gridprotectionalliance.org/u/clackner-gpa)\
**Post date:** [June 26, 2025, 2:35pm UTC](http://discussions.gridprotectionalliance.org/t/filter-data-based-on-value-for-count-query/1425/2 "2025-06-26T14:35:21Z")

</div>

Hi,

You can try something like `Count(IncludeRange(0.5, 2,FILTER ActiveMeasurements WHERE PointTag = ‘LOW_GAS’))`

This would exclude any values below `0.5` and above `2`

---

<div class="post-metadata">

**Author:** ![jarurlaj](http://discussions.gridprotectionalliance.org/letter_avatar_proxy/v4/letter/j/9dc877/32.png) [@jarurlaj](http://discussions.gridprotectionalliance.org/u/jarurlaj)\
**Post date:** [June 26, 2025, 2:47pm UTC](http://discussions.gridprotectionalliance.org/t/filter-data-based-on-value-for-count-query/1425/3 "2025-06-26T14:47:46Z")

</div>

Great! This is what I was looking for! I actually realize now that this type of point maintains a value of 1 the entire time that the point is tripped. In actuality, I would be counting the instances when the point switches from 0 to 1. Would it be possible to nest aggregate functions in Grafana? For example:

> Count(IncludeRange(-0.5, -2, Difference(FILTER ActiveMeasurements WHERE PointTag = ‘LOW\_GAS’)))

---

<div class="post-metadata">

**Author:** ![clackner-gpa](http://discussions.gridprotectionalliance.org/user_avatar/discussions.gridprotectionalliance.org/clackner-gpa/32/556_2.png) [@clackner-gpa](http://discussions.gridprotectionalliance.org/u/clackner-gpa)\
**Post date:** [June 26, 2025, 3:03pm UTC](http://discussions.gridprotectionalliance.org/t/filter-data-based-on-value-for-count-query/1425/4 "2025-06-26T15:03:32Z")

</div>

You have a few options here, They have slightly different performance implications and may behave differently in edge cases (e.g. 0 switches to 1 before your time range starts, but switches back post time range).

You can certainly nest aggregated functions, I would recommend one of the following:  
[ExceedsAt](https://github.com/GridProtectionAlliance/gsf/blob/master/Source/Documentation/GrafanaFunctions.md#exceedsat)  
[Difference](https://github.com/GridProtectionAlliance/gsf/blob/master/Source/Documentation/GrafanaFunctions.md#difference)

Noting that the `ExceedsAt` will return more information, inlcuding the duration of the trip etc.
