# Adding field to time series based on separate record

**URL:** <https://community.dynatrace.com/t/adding-field-to-time-series-based-on-separate-record/50328>\
**Category:** DQL\
**Tags:** dql, dashboards\
**Created:** [February 18, 2025, 10:47pm UTC](https://community.dynatrace.com/t/adding-field-to-time-series-based-on-separate-record/50328 "2025-02-18T22:47:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulito](https://avatars.discourse-cdn.com/v4/letter/p/e19adc/32.png) [@paulito](https://community.dynatrace.com/u/paulito)\
**Post date:** [February 18, 2025, 10:47pm UTC](https://community.dynatrace.com/t/adding-field-to-time-series-based-on-separate-record/50328/1 "2025-02-18T22:47:23Z")

</div>

I have a time series with statuses from 0-12. I’d like to replace these status numbers with words as follows:

```markup
timeseries PR1_status = avg(PR1_status), by: { device }
| join [
      data record(Status = "Unknown", PR1_status= 0),
record(Status = "Up", PR1_status= 1),
record(Status = "Down", PR1_status= 2),
record(Status = "Warning", PR1_status= 3),
record(Status = "Shutdown", PR1_status= 4),
record(Status = "Testing", PR1_status= 5),
record(Status = "Dormant", PR1_status= 6),
record(Status = "Not Present", PR1_status= 7),
record(Status = "Lower Layer Down", PR1_status= 8),
record(Status = "Unmanaged", PR1_status= 9),
record(Status = "Unplugged", PR1_status= 10),
record(Status = "External", PR1_status= 11),
record(Status = "Unreachable", PR1_status= 12)
    ],
    kind: leftOuter,
    on: { PR1_status}
| fieldsRemove right.PR1_status

```

I get the following error:&nbsp;_The data types are incompatible. Please change the expressions and try again. Using the `to…` conversion functions could help._

I’m not sure if join is the best way to go about this but any help would be appreciated.

---

<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:** [February 19, 2025, 6:39am UTC](https://community.dynatrace.com/t/adding-field-to-time-series-based-on-separate-record/50328/2 "2025-02-19T06:39:05Z")

</div>

PR1\_status is an array so it cannot be used in join condition directly.

I see that you are trying to translate numeric statues into text and the list of possibilities is rather short and static. This could be a query solving it:

```markup
timeseries PR1_status = avg(PR1_status), by: { device }
| fieldsAdd Status=coalesce(
if(PR1_status[]== 0,"Unknown"),
if(PR1_status[]== 1,"Up"),
if(PR1_status[]== 2,"Down"),
if(PR1_status[]== 3,"Warning"),
if(PR1_status[]== 4,"Shutdown"),
if(PR1_status[]== 5,"Testins"),
if(PR1_status[]== 6,"Dormant"),
if(PR1_status[]== 7,"Not Present"),
if(PR1_status[]== 8,"Lower Layer Down"),
if(PR1_status[]== 9,"Unmanaged"),
if(PR1_status[]== 10,"Unplugged"),
if(PR1_status[]== 11,"External"),
if(PR1_status[]== 12,"Unreachable")
)

```

on simulated data it looks like this:

 ![krzysztof_hoja_1-1739947124863.png](https://global.discourse-cdn.com/dynatrace/original/3X/2/0/201954e1a00e54d77ac456d411c281f61ba1e983.png)

---

<div class="post-metadata">

**Author:** ![paulito](https://avatars.discourse-cdn.com/v4/letter/p/e19adc/32.png) [@paulito](https://community.dynatrace.com/u/paulito)\
**Post date:** [February 19, 2025, 3:49pm UTC](https://community.dynatrace.com/t/adding-field-to-time-series-based-on-separate-record/50328/3 "2025-02-19T15:49:11Z")

</div>

This does work but I’m trying to get the words to show up on a line graph instead of just “1” when a device is up or “2” when it’s down. It’d be nice to also get the words on the y axis.

Not sure if this is possible as the data mapping asks for a numeric field.

I’ve attached an image showing what I’m trying to do.

Thanks again.

 ![Untitled.png](https://global.discourse-cdn.com/dynatrace/original/3X/7/4/74d858a9510b24bfda3a743fa0c7038aa9d18684.png)

---

<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:** [February 19, 2025, 5:16pm UTC](https://community.dynatrace.com/t/adding-field-to-time-series-based-on-separate-record/50328/4 "2025-02-19T17:16:33Z")

</div>

Unfortunately this visualization as well as other currently available does not allow it. Line/bar/area chart are designed to display metrics (continuous space of values) and what you are looking for is state tracking over time.

What is possible to do is e.g. see number of devices in each state for each interval. And in this case each of series would be labeled with word
