# add a timeseries field

**URL:** <https://community.dynatrace.com/t/add-a-timeseries-field/52501>\
**Category:** DQL\
**Tags:** dql, timeseries\
**Created:** [July 16, 2025, 8:21am UTC](https://community.dynatrace.com/t/add-a-timeseries-field/52501 "2025-07-16T08:21:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![khoros\_anonymous](https://avatars.discourse-cdn.com/v4/letter/k/f9ae1b/32.png) [@khoros\_anonymous](https://community.dynatrace.com/u/khoros_anonymous)\
**Post date:** [July 16, 2025, 8:21am UTC](https://community.dynatrace.com/t/add-a-timeseries-field/52501/1 "2025-07-16T08:21:46Z")

</div>

Hi,

Here is a simple dql example to ilustrate my issue

_timeseries test=avg(dt.host.cpu.usage), by:{dt.entity.host}_  
_| fieldsadd cpu\_state=if(arrayAvg(test)\>7,1,else:0)_

I would like to see history of cpu\_state, but I always have one value (may be due to the arrayAvg). How can I see cpu state as a graph and see the value evolution?

Regards,

Marc

---

<div class="post-metadata">

**Author:** ![GerardJ](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/gerardj/32/154_2.png) [@GerardJ](https://community.dynatrace.com/u/GerardJ)\
**Post date:** [July 16, 2025, 8:52am UTC](https://community.dynatrace.com/t/add-a-timeseries-field/52501/2 "2025-07-16T08:52:57Z")

</div>

Hi&nbsp;@Anonymous&nbsp;  
I don’t really understand what you want to do, could you elaborate a bit more on your use case and what you want to achieve?

---

<div class="post-metadata">

**Author:** ![khoros\_anonymous](https://avatars.discourse-cdn.com/v4/letter/k/f9ae1b/32.png) [@khoros\_anonymous](https://community.dynatrace.com/u/khoros_anonymous)\
**Post date:** [July 16, 2025, 9:43am UTC](https://community.dynatrace.com/t/add-a-timeseries-field/52501/3 "2025-07-16T09:43:01Z")

</div>

Hi Gerard,  
Of course  
If I just create this dql  
_timeseries test=avg(dt.host.cpu.usage), by:{dt.entity.host}_  
I get a graph of cpu usage evolution for each host based on the time windows I have selected in the dashboard.  
Suppose now that I want to create a new&nbsp; field named status on cpu usage wher rule is the following  
if cpu\_usage&nbsp; is above 7 then state = 1

if cpu\_usage is below 7 then state =0

I would like to display state graph based on the time windows I have selected in the dashboard.  
How can I do that?

---

<div class="post-metadata">

**Author:** ![GerardJ](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/gerardj/32/154_2.png) [@GerardJ](https://community.dynatrace.com/u/GerardJ)\
**Post date:** [July 16, 2025, 12:00pm UTC](https://community.dynatrace.com/t/add-a-timeseries-field/52501/4 "2025-07-16T12:00:14Z")

</div>

Ok I got it  
So what you want is something like that :

 ![GerardJ_0-1752666834392.png](https://global.discourse-cdn.com/dynatrace/original/3X/0/5/0591c96f428263768a2458122a31d0e9072ed2cd.png)

here I use an iterative expression to compare each timeserie array value to the treshold  
I choose to display it as a table for clarity but you can also use this state array in a graph

 ![GerardJ_3-1752667198370.png](https://global.discourse-cdn.com/dynatrace/original/3X/2/c/2c7a7727fcf0c1e00121667965a50fe17fe19322.png)

There are other possibilities,&nbsp;for display purposes for example i’d rather use the thresholds which have the advantage of being visual while preserving the true cpu values on the graph.

 ![GerardJ_4-1752667518660.png](https://global.discourse-cdn.com/dynatrace/original/3X/a/e/ae7da77d65c9ffae4d65120df1e81dcba73821b2.png)
