# How to create a line graph comparing this week and last week

**URL:** <https://community.dynatrace.com/t/how-to-create-a-line-graph-comparing-this-week-and-last-week/54163>\
**Category:** Dashboarding\
**Tags:** dql, dashboards\
**Created:** [November 21, 2025, 7:10am UTC](https://community.dynatrace.com/t/how-to-create-a-line-graph-comparing-this-week-and-last-week/54163 "2025-11-21T07:10:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Taihei](https://avatars.discourse-cdn.com/v4/letter/t/71e660/32.png) [@Taihei](https://community.dynatrace.com/u/Taihei)\
**Post date:** [November 21, 2025, 7:10am UTC](https://community.dynatrace.com/t/how-to-create-a-line-graph-comparing-this-week-and-last-week/54163/1 "2025-11-21T07:10:18Z")

</div>

I created the following DQL to generate this graph.  
It adds and removes fields within the timeframe.  
Is there a more efficient way to achieve this?

timeseries req\_now=avg(dt.service.request.response\_time),timeframe:“2025-11-21T12:00:00+0900/2025-11-21T15:00:00+0900”  
| fields interval, req\_now  
| fieldsAdd timeframe = timeframe(from:“2025-11-14T12:00:00+0900”,to:“2025-11-14T15:00:00+0900” )  
| append [  
timeseries {req\_old=avg(dt.service.request.response\_time),timeframe:“2025-11-14T12:00:00+0900/2025-11-14T15:00:00+0900”}  
]

---

<div class="post-metadata">

**Author:** ![waikeat\_chan](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/waikeat_chan/32/33405_2.png) [@waikeat\_chan](https://community.dynatrace.com/u/waikeat_chan)\
**Post date:** [November 21, 2025, 7:18am UTC](https://community.dynatrace.com/t/how-to-create-a-line-graph-comparing-this-week-and-last-week/54163/2 "2025-11-21T07:18:12Z")

</div>

For last week:

**| fieldsAdd startTime=-1w@w, endTime=@w-1s**  
| fieldsAdd startTime=formatTimestamp(startTime, format:“MMM-dd-yyyy”)  
| fieldsAdd endTime=formatTimestamp(endTime, format:“MMM-dd-yyyy”)  
| fieldsAdd WeekNumber = getWeekOfYear(-1w@w)

For current week:

**| fieldsAdd startTime=@w, endTime=now()**
