# Hide Data outside timerange message?

**URL:** <https://community.grafana.com/t/hide-data-outside-timerange-message/123715>\
**Category:** Dashboards\
**Tags:** sql\
**Created:** [June 11, 2024, 12:34pm UTC](https://community.grafana.com/t/hide-data-outside-timerange-message/123715 "2024-06-11T12:34:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tadeasvintrlik1](https://avatars.discourse-cdn.com/v4/letter/t/a87d85/32.png) [@tadeasvintrlik1](https://community.grafana.com/u/tadeasvintrlik1)\
**Post date:** [June 11, 2024, 12:34pm UTC](https://community.grafana.com/t/hide-data-outside-timerange-message/123715/1 "2024-06-11T12:34:12Z")

</div>

I am using Grafana v10.4.1. I use the PostgreSQL datasource.

I am using it to connect to our build system’s database (buildbot).  
This contains information about build results.

I am using a query like this

```sql
SELECT
  builders.name as builder_name,
  TO_TIMESTAMP(builds.complete_at) as complete_time,
  builds.results
FROM
  builds
  INNER JOIN builders ON builds.builderid = builders.id

```

I then transform it into a multi-frame time series and visualize it as a state timeline.

 ![image](https://us1.discourse-cdn.com/grafana/original/3X/a/b/abe18d988682e9bc09dd231a494ea18d3285a44a.png)

This is what it looks like. I know the message is because the complete\_at is outside the grafana dashboard time range. However I want to also see build’s last state that are outside this time range so this is intentional.

What would be the solution here?

---

<div class="post-metadata">

**Author:** ![cschlipf](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/cschlipf/32/49871_2.png) [@cschlipf](https://community.grafana.com/u/cschlipf)\
**Post date:** [August 16, 2026, 4:43pm UTC](https://community.grafana.com/t/hide-data-outside-timerange-message/123715/2 "2026-08-16T16:43:49Z")

</div>

You need to add a WHERE clause to filter the data for the current time range.

This is the answer that you typically get in these cases. But it doesn’t always fix the issue in all cases.

---

<div class="post-metadata">

**Author:** ![infofcc3](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/infofcc3/32/51248_2.png) [@infofcc3](https://community.grafana.com/u/infofcc3)\
**Post date:** [August 17, 2026, 2:43am UTC](https://community.grafana.com/t/hide-data-outside-timerange-message/123715/3 "2026-08-17T02:43:15Z")

</div>

The state timeline only draws from data points it receives. If a builder’s last result happened before your dashboard’s time range starts, there’s no point for it to draw from, hence “Data outside time range.”

**Fix: →** inject a synthetic point at the start of the range for each builder, carrying forward its last known result. Use `UNION ALL` → one branch gets the last row per builder before the range starts, the other is your normal in-range query →

sql

```auto
SELECT * FROM (
  SELECT DISTINCT ON (builders.name)
    builders.name AS builder_name,
    TO_TIMESTAMP($__unixEpochFrom() + 1) AS complete_time,
    builds.results
  FROM builds
  INNER JOIN builders ON builds.builderid = builders.id
  WHERE builds.complete_at < $__unixEpochFrom()
  ORDER BY builders.name, builds.complete_at DESC
) AS last_known

UNION ALL

SELECT
  builders.name AS builder_name,
  TO_TIMESTAMP(builds.complete_at) AS complete_time,
  builds.results
FROM builds
INNER JOIN builders ON builds.builderid = builders.id
WHERE builds.complete_at >= $__unixEpochFrom()
  AND builds.complete_at <= $__unixEpochTo()

ORDER BY builder_name, complete_time

```

 ![Screenshot (522)](https://us1.discourse-cdn.com/grafana/original/3X/c/2/c2e14695675ce5113a145beae04722ba0e25636d.png)  
 ![Screenshot (527)](https://us1.discourse-cdn.com/grafana/original/3X/5/d/5d9b651e545e5388878b90ba793b00ea28179cb0.png)

Two things that matter →

`+ 1` on `$__unixEpochFrom()` → pinning the synthetic timestamp exactly on the boundary still gets flagged as “outside” the range by the panel; nudging it one second inside fixes it.

Apply the “Prepare time series → Multi-frame time series” transform to the query result → without it, the state timeline won’t split the flat SQL output into one series per builder.

Builders with no prior build at all correctly still show a gap, since there’s genuinely nothing to carry forward.
