# Using multiple timeframes in a single query with lookups

**URL:** <https://community.dynatrace.com/t/using-multiple-timeframes-in-a-single-query-with-lookups/41131>\
**Category:** DQL\
**Tags:** dql\
**Created:** [August 9, 2023, 1:27pm UTC](https://community.dynatrace.com/t/using-multiple-timeframes-in-a-single-query-with-lookups/41131 "2023-08-09T13:27:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![PiotrG](https://avatars.discourse-cdn.com/v4/letter/p/e47774/32.png) [@PiotrG](https://community.dynatrace.com/u/PiotrG)\
**Post date:** [August 9, 2023, 1:27pm UTC](https://community.dynatrace.com/t/using-multiple-timeframes-in-a-single-query-with-lookups/41131/1 "2023-08-09T13:27:05Z")

</div>

Hey!

```c-mrkdwn__pre
fetch dt.entity.host, from: now()-15m //1
[...]
| lookup [ fetch events, from: now()-3h //2
  ...]
| lookup [ timeframe, //3
  ...]
[rest of the main host query]

```

I’m wondering about the timeframes that would be used in this query.  
1 is clear, I’m sure it will use last 15 minutes.  
2 also seems clear, if it’s alright to alter the timeframe within a lookup command  
3 I’m not sure about, if no timeframe is provided in a lookup query does it inherit timeframe from the original query or will it use last set timeframe or is the behaviour completely different?  
Thanks!

---

<div class="post-metadata">

**Author:** ![sinisa\_zubic](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/sinisa_zubic/32/32498_2.png) [@sinisa\_zubic](https://community.dynatrace.com/u/sinisa_zubic)\
**Post date:** [August 9, 2023, 2:00pm UTC](https://community.dynatrace.com/t/using-multiple-timeframes-in-a-single-query-with-lookups/41131/2 "2023-08-09T14:00:23Z")

</div>

Hi&nbsp;[@PiotrG](https://community.dynatrace.com/user/55118)

I have just tried it out by executing following query:

```markup
fetch dt.entity.host, from:now() -15m
| fieldsAdd key = 1
| lookup [fetch events, from:now()-180m, to:now()-175m | fieldsAdd key=1 | sort timestamp asc | fields timestamp,key], sourceField:key, lookupField:key, prefix:"withTF."
| lookup [fetch events | fieldsAdd key=1 | sort timestamp asc | fields timestamp,key], sourceField:key, lookupField:key, prefix:"withoutTF."
| fields from= now()-15m, withTF.timestamp, withoutTF.timestamp

```

If you don’t specify the TF in the lookup, then the TF is inherited from the original query.

Best,  
Sini
