# Shift Time Frame In a Dashboard Using a Input Variable

**URL:** <https://community.dynatrace.com/t/shift-time-frame-in-a-dashboard-using-a-input-variable/56822>\
**Category:** DQL\
**Tags:** dql, timeframe, variables, dashboards\
**Created:** [August 26, 2026, 6:48pm UTC](https://community.dynatrace.com/t/shift-time-frame-in-a-dashboard-using-a-input-variable/56822 "2026-08-26T18:48:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![victor\_correa](https://avatars.discourse-cdn.com/v4/letter/v/90ced4/32.png) [@victor\_correa](https://community.dynatrace.com/u/victor_correa)\
**Post date:** [August 26, 2026, 6:48pm UTC](https://community.dynatrace.com/t/shift-time-frame-in-a-dashboard-using-a-input-variable/56822/1 "2026-08-26T18:48:05Z")

</div>

I’m building a comparative transaction dashboard that should display day for the current time frame but also data shifted by a number of days that will be a variable input.

The goal is to be able to show current data versus a comparison with what the numbers look like “N” days ago and then calculate the variance.

The structure of the table I am trying to create would look like this:

 ![victor_correa_0-1787769992549.png](https://global.discourse-cdn.com/dynatrace/original/3X/7/2/7254320f7b956239a5459d803eeceb2f87d26c82.png)

I have been able to create something close to what I need using the following:

```markup
fetch bizevents,from: now()@d - (toLong($TxCountNDaysAgo) * 1d), to:now()@d - ((toLong($TxCountNDaysAgo)-1) * 1d)

```

But if I select a time frame with a specific start time and end time, the shifted data will show the data for the full day, rather than just shifted by the number of days I have chosen.

I have tried shifting time using Unix Time, but then I can’t set the parameter “from” and “to” with the values I generated:

```markup
fetch bizevents 
| fieldsAdd currentTimeStampUnix = unixSecondsFromTimestamp(timestamp) 
| fieldsAdd shiftedTimeStampUnix = unixSecondsFromTimestamp(timestamp) - 86400 
| fieldsAdd currentTimeStamp = timestampFromUnixSeconds(currentTimeStampUnix), shiftedTimeStamp = timestampFromUnixSeconds(shiftedTimeStampUnix)

```

I’m wondering if anyone has done something along those lines and can share their insights on how they accomplished it.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![victor\_correa](https://avatars.discourse-cdn.com/v4/letter/v/90ced4/32.png) [@victor\_correa](https://community.dynatrace.com/u/victor_correa)\
**Post date:** [August 26, 2026, 8:03pm UTC](https://community.dynatrace.com/t/shift-time-frame-in-a-dashboard-using-a-input-variable/56822/2 "2026-08-26T20:03:04Z")

</div>

**Update:**  
I have managed to do the time shifts statically by using Unix Time and the Internal Variables “dt\_timeframe\_to” and “dt\_timeframe\_from”:

```markup
fetch bizevents,
   from: timestampFromUnixSeconds(unixSecondsFromTimestamp($dt_timeframe_from) - 86400), 
   to: timestampFromUnixSeconds(unixSecondsFromTimestamp($dt_timeframe_to) - 86400)

```

But Dynatrace won’t let me use variables in the “from” and “to” parameters, so I have to define the shift explicitly with numbers, which defeats the purpose of what I’m trying to do.

Dynatrace won’t let me change the values of the interval variables either, as that would solve my problem.

---

<div class="post-metadata">

**Author:** ![zietho](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/zietho/32/41733_2.png) [@zietho](https://community.dynatrace.com/u/zietho)\
**Post date:** [September 14, 2026, 3:46pm UTC](https://community.dynatrace.com/t/shift-time-frame-in-a-dashboard-using-a-input-variable/56822/3 "2026-09-14T15:46:21Z")

</div>

can you explain the following further please?

“But Dynatrace won’t let me use variables in the “from” and “to” parameters,”

---

<div class="post-metadata">

**Author:** ![krzysztof\_hoja](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/krzysztof_hoja/32/34625_2.png) [@krzysztof\_hoja](https://community.dynatrace.com/u/krzysztof_hoja)\
**Post date:** [September 14, 2026, 4:15pm UTC](https://community.dynatrace.com/t/shift-time-frame-in-a-dashboard-using-a-input-variable/56822/4 "2026-09-14T16:15:14Z")

</div>

You can use whatever is needed in from: and to: as long as it is constant expression. Here is the example of a query showing side by side data shifted by selected number of days (defined in variable)

```markup
fetch bizevents,
   from: toTimestamp($dt_timeframe_from), 
   to: toTimestamp($dt_timeframe_to)
| makeTimeseries x = count()

| lookup [

fetch bizevents,
   from: toTimestamp($dt_timeframe_from) - $offset:noquote * 1d, 
   to: toTimestamp($dt_timeframe_to) - $offset:noquote * 1d
| makeTimeseries x_ref = count()

], sourceField: interval, lookupField: interval, fields: { x_ref }

```

Result looks like this, but you are free to perform any other operation on data.

 ![krzysztof_hoja_0-1789402480830.png](https://global.discourse-cdn.com/dynatrace/original/3X/5/e/5ee7bfb7eda8d102ccba0c7bd473dc7110f04667.png)
