# DQL query to replace null values into an integer in a array

**URL:** <https://community.dynatrace.com/t/dql-query-to-replace-null-values-into-an-integer-in-a-array/48896>\
**Category:** DQL\
**Tags:** dql, dynatrace-managed\
**Created:** [November 14, 2024, 1:33pm UTC](https://community.dynatrace.com/t/dql-query-to-replace-null-values-into-an-integer-in-a-array/48896 "2024-11-14T13:33:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Elumalai](https://avatars.discourse-cdn.com/v4/letter/e/54ee81/32.png) [@Elumalai](https://community.dynatrace.com/u/Elumalai)\
**Post date:** [November 14, 2024, 1:33pm UTC](https://community.dynatrace.com/t/dql-query-to-replace-null-values-into-an-integer-in-a-array/48896/1 "2024-11-14T13:33:29Z")

</div>

Hi Team,

I’m using single synthetic monitoring configuration where I have configured 3 http requests and I would like to monitor all 3 http url in a dashboard. If any http url receives status code other than 200 then it should fail.

I use below DQL query to fetch the metrics, the average value **dt.synthetic.http.request.executions** comes 1 if there is a success and gives null when it fails.

When I try to fetch arraylast() value, DQL ignores all null values and picks latest numerical value from an array. Is there a function to change null values into numerical value i.e 0 so that I can pick that value and mark my application down.

**timeseries requests = avg(dt.synthetic.http.request.executions),**  
**filter: { http\_monitor.result.http\_status.code == 200 AND matchesValue(entityAttr(dt.entity.http\_check\_step, “entity.name”), “test-monitor”) }**  
**| fieldsAdd final=if(arrayLast(requests)==1, “UP”, else: “DOWN”)**

---

<div class="post-metadata">

**Author:** ![marina\_pollehn](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/marina_pollehn/32/39120_2.png) [@marina\_pollehn](https://community.dynatrace.com/u/marina_pollehn)\
**Post date:** [November 14, 2024, 3:08pm UTC](https://community.dynatrace.com/t/dql-query-to-replace-null-values-into-an-integer-in-a-array/48896/2 "2024-11-14T15:08:59Z")

</div>

Can you try this? 🙂

timeseries requests = avg(dt.synthetic.http.request.executions),  
filter: { http\_monitor.result.http\_status.code == 200 AND matchesValue(entityAttr(dt.entity.http\_check\_step, “entity.name”), “test-monitor”) }  
| fieldsAdd requests =if(isNull(requests[]),0,else:requests[])

| fieldsAdd final=if(arrayLast(requests)==1, “UP”, else: “DOWN”)

---

<div class="post-metadata">

**Author:** ![Elumalai](https://avatars.discourse-cdn.com/v4/letter/e/54ee81/32.png) [@Elumalai](https://community.dynatrace.com/u/Elumalai)\
**Post date:** [November 14, 2024, 4:20pm UTC](https://community.dynatrace.com/t/dql-query-to-replace-null-values-into-an-integer-in-a-array/48896/3 "2024-11-14T16:20:23Z")

</div>

This works, much appreciated
