<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Replace null Values with previous non-Null value in an array in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/Replace-null-Values-with-previous-non-Null-value-in-an-array/m-p/275988#M2001</link>
    <description>&lt;P&gt;Hello,&lt;BR /&gt;Thanks for the answer!&lt;BR /&gt;In my case it is specifically for anomaly detection, i want to trigger an alert if every datapoint is below a certain threshold for an hour. But if some of the values are NULL within that hour the alert does not trigger. I can just assume NULL values are in breach of the threshold by forcing them to be a specific value, but then it gives a graph going up and down (but it still works)&lt;/P&gt;</description>
    <pubDate>Fri, 25 Apr 2025 18:52:43 GMT</pubDate>
    <dc:creator>SimGiants92</dc:creator>
    <dc:date>2025-04-25T18:52:43Z</dc:date>
    <item>
      <title>Replace null Values with previous non-Null value in an array</title>
      <link>https://community.dynatrace.com/t5/DQL/Replace-null-Values-with-previous-non-Null-value-in-an-array/m-p/275792#M1979</link>
      <description>&lt;P&gt;I have arrays that contain a lot of null values but i would like to replace them not with a single value but instead with whatever previous value in the array is not null, is this possible in DQL?&lt;/P&gt;</description>
      <pubDate>Wed, 23 Apr 2025 19:08:59 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Replace-null-Values-with-previous-non-Null-value-in-an-array/m-p/275792#M1979</guid>
      <dc:creator>SimGiants92</dc:creator>
      <dc:date>2025-04-23T19:08:59Z</dc:date>
    </item>
    <item>
      <title>Re: Replace null Values with previous non-Null value in an array</title>
      <link>https://community.dynatrace.com/t5/DQL/Replace-null-Values-with-previous-non-Null-value-in-an-array/m-p/275800#M1982</link>
      <description>&lt;P&gt;Unfortunately we do not have such array function yet, but there is a trick which can be used if you know maximum number of consecutive nulls in your array.&lt;BR /&gt;&lt;BR /&gt;If you can have max 2 nulls in row, query could look like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;data record(a=array(1.0 ,null, 2.5, 3.0, null, null, 1.1))

| fieldsAdd a = if( isNotNull(a[]), a[], else: arrayMovingMin(a, 2)[] )
| fieldsAdd a = if( isNotNull(a[]), a[], else: arrayMovingMin(a, 2)[] )
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;If more, you need to repeat last command more times.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="krzysztof_hoja_0-1745441525970.png" style="width: 832px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/27696iE7ED02D0E4E59652/image-dimensions/832x312?v=v2" width="832" height="312" role="button" title="krzysztof_hoja_0-1745441525970.png" alt="krzysztof_hoja_0-1745441525970.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;but:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="krzysztof_hoja_1-1745441560325.png" style="width: 849px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/27697i3F70C9FACA10A51F/image-dimensions/849x329?v=v2" width="849" height="329" role="button" title="krzysztof_hoja_1-1745441560325.png" alt="krzysztof_hoja_1-1745441560325.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Apr 2025 20:53:45 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Replace-null-Values-with-previous-non-Null-value-in-an-array/m-p/275800#M1982</guid>
      <dc:creator>krzysztof_hoja</dc:creator>
      <dc:date>2025-04-23T20:53:45Z</dc:date>
    </item>
    <item>
      <title>Re: Replace null Values with previous non-Null value in an array</title>
      <link>https://community.dynatrace.com/t5/DQL/Replace-null-Values-with-previous-non-Null-value-in-an-array/m-p/275858#M1988</link>
      <description>&lt;P&gt;Thanks for the answer, I can't know how many consecutive NULL i will have ahead of time but at least i have an idea of a different solution and i know the function does not exist&lt;/P&gt;</description>
      <pubDate>Thu, 24 Apr 2025 13:30:03 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Replace-null-Values-with-previous-non-Null-value-in-an-array/m-p/275858#M1988</guid>
      <dc:creator>SimGiants92</dc:creator>
      <dc:date>2025-04-24T13:30:03Z</dc:date>
    </item>
    <item>
      <title>Re: Replace null Values with previous non-Null value in an array</title>
      <link>https://community.dynatrace.com/t5/DQL/Replace-null-Values-with-previous-non-Null-value-in-an-array/m-p/275986#M2000</link>
      <description>&lt;P&gt;Friend showed me this solution not having this limitation:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;data record(a=array(1.0 ,null, 2.5, 3.0, null, null, null, 1.1))

| fieldsAdd va=record(a=a[], i=iIndex())
| expand va
| fieldsAdd fixedValue = if(isNotNull(va[a]), va[a], else: arrayLast(arrayRemoveNulls( iCollectArray( if(iIndex() &amp;lt; va[i], a[])))))

| summarize a=collectArray(record(va[i],a=fixedValue))
| fieldsAdd a=arraySort(a, direction:"ascending")
| fieldsAdd a=a[][a]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="krzysztof_hoja_0-1745606603349.png" style="width: 768px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/27732iF30308CB5DFA5FA4/image-dimensions/768x233?v=v2" width="768" height="233" role="button" title="krzysztof_hoja_0-1745606603349.png" alt="krzysztof_hoja_0-1745606603349.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;credits go to&amp;nbsp;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/86520"&gt;@AustinSabel&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/87981"&gt;@SimGiants92&lt;/a&gt;&amp;nbsp;, can you tell us more about the need behind this operation? In what situation do you need it. I think there may be a value in having dedicated utility function doing it in one step.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Apr 2025 18:46:52 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Replace-null-Values-with-previous-non-Null-value-in-an-array/m-p/275986#M2000</guid>
      <dc:creator>krzysztof_hoja</dc:creator>
      <dc:date>2025-04-25T18:46:52Z</dc:date>
    </item>
    <item>
      <title>Re: Replace null Values with previous non-Null value in an array</title>
      <link>https://community.dynatrace.com/t5/DQL/Replace-null-Values-with-previous-non-Null-value-in-an-array/m-p/275988#M2001</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;Thanks for the answer!&lt;BR /&gt;In my case it is specifically for anomaly detection, i want to trigger an alert if every datapoint is below a certain threshold for an hour. But if some of the values are NULL within that hour the alert does not trigger. I can just assume NULL values are in breach of the threshold by forcing them to be a specific value, but then it gives a graph going up and down (but it still works)&lt;/P&gt;</description>
      <pubDate>Fri, 25 Apr 2025 18:52:43 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Replace-null-Values-with-previous-non-Null-value-in-an-array/m-p/275988#M2001</guid>
      <dc:creator>SimGiants92</dc:creator>
      <dc:date>2025-04-25T18:52:43Z</dc:date>
    </item>
  </channel>
</rss>

