<?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: Time difference DQL in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/Time-difference-DQL/m-p/272892#M1825</link>
    <description>&lt;P&gt;Here is an example calculating duration, hope it helps:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;data 
record(content="79895474545006\tPreProcessing\tstart\t1\t\t2023-04-27 04:23:12.000.153"),
record(content="79895474545006\tPreProcessing\tend\t1\t\t2023-04-27 04:30:38.000.153"),
record(content="79895474545005\tPreProcessing\tstart\t1\t\t2023-04-26 05:30:38.000.1538"),
record(content="79895474545005\tPreProcessing\tend\t1\t\t2023-04-27 04:30:38.000.153")
| parse content, """ALNUM:batch.id '\t' STRING:stage  '\t'  LDATA:stage_status '\t' INT?:valid '\t' FLOAT?:result PUNCT? '\t' TIMESTAMP('yyyy-MM-DD HH:mm:ss'):timestamp"""
| filter stage == "PreProcessing"
| summarize {start=takeFirst(if(stage_status=="start",timestamp)), end=takeFirst(if(stage_status=="end",timestamp))}, by:{batch.id, stage} 
| fieldsAdd duration = end - start
&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="mark_bley_1-1742372696814.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/27038iDD89DADD7E4F8840/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mark_bley_1-1742372696814.png" alt="mark_bley_1-1742372696814.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 19 Mar 2025 08:25:36 GMT</pubDate>
    <dc:creator>mark_bley</dc:creator>
    <dc:date>2025-03-19T08:25:36Z</dc:date>
    <item>
      <title>Time difference DQL</title>
      <link>https://community.dynatrace.com/t5/DQL/Time-difference-DQL/m-p/272688#M1813</link>
      <description>&lt;P&gt;Hello Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Good day,&lt;/P&gt;&lt;P&gt;I have a requirement to calculate the time difference between the minimum and first maximum points for all the available data within the timeframe selected. In this example, the time taken for the value to reach 98 from 0.&amp;nbsp; I'm able to get the latest output using the below DQL. Is there any trick to getting the output of the complete timeframe we selected?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DQL Used&lt;/P&gt;&lt;P&gt;timeseries count = max(appl.completed), timestamp=start()&lt;BR /&gt;| fieldsAdd d=record(count=count[], timestamp=timestamp[])&lt;BR /&gt;| fieldsAdd d = arrayRemoveNulls( iCollectArray( if(d[][count]&amp;gt;97, d[] )))&lt;BR /&gt;| expand d&lt;BR /&gt;| fieldsAdd e=record(count1=count[], timestamp1=timestamp[])&lt;BR /&gt;| fieldsAdd e = arrayRemoveNulls( iCollectArray( if(e[][count1]&amp;lt;1 AND e[][timestamp1] &amp;lt; d[timestamp], e[] )))&lt;BR /&gt;| expand e&lt;BR /&gt;| summarize d=takeFirst(d), e=takeLast(e)&lt;BR /&gt;| fieldsAdd m = d[timestamp], n = e[timestamp1]&lt;BR /&gt;| fieldsAdd A = m - n&lt;BR /&gt;| fields A&lt;/P&gt;</description>
      <pubDate>Mon, 17 Mar 2025 10:31:32 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Time-difference-DQL/m-p/272688#M1813</guid>
      <dc:creator>RAKESHNREDDY</dc:creator>
      <dc:date>2025-03-17T10:31:32Z</dc:date>
    </item>
    <item>
      <title>Re: Time difference DQL</title>
      <link>https://community.dynatrace.com/t5/DQL/Time-difference-DQL/m-p/272892#M1825</link>
      <description>&lt;P&gt;Here is an example calculating duration, hope it helps:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;data 
record(content="79895474545006\tPreProcessing\tstart\t1\t\t2023-04-27 04:23:12.000.153"),
record(content="79895474545006\tPreProcessing\tend\t1\t\t2023-04-27 04:30:38.000.153"),
record(content="79895474545005\tPreProcessing\tstart\t1\t\t2023-04-26 05:30:38.000.1538"),
record(content="79895474545005\tPreProcessing\tend\t1\t\t2023-04-27 04:30:38.000.153")
| parse content, """ALNUM:batch.id '\t' STRING:stage  '\t'  LDATA:stage_status '\t' INT?:valid '\t' FLOAT?:result PUNCT? '\t' TIMESTAMP('yyyy-MM-DD HH:mm:ss'):timestamp"""
| filter stage == "PreProcessing"
| summarize {start=takeFirst(if(stage_status=="start",timestamp)), end=takeFirst(if(stage_status=="end",timestamp))}, by:{batch.id, stage} 
| fieldsAdd duration = end - start
&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="mark_bley_1-1742372696814.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/27038iDD89DADD7E4F8840/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mark_bley_1-1742372696814.png" alt="mark_bley_1-1742372696814.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Mar 2025 08:25:36 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Time-difference-DQL/m-p/272892#M1825</guid>
      <dc:creator>mark_bley</dc:creator>
      <dc:date>2025-03-19T08:25:36Z</dc:date>
    </item>
    <item>
      <title>Re: Time difference DQL</title>
      <link>https://community.dynatrace.com/t5/DQL/Time-difference-DQL/m-p/272908#M1831</link>
      <description>&lt;P&gt;Thanks Mark, tried including the 'By: Day' with a few modifications in the summarize. Works fine now.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Mar 2025 09:54:59 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Time-difference-DQL/m-p/272908#M1831</guid>
      <dc:creator>RAKESHNREDDY</dc:creator>
      <dc:date>2025-03-19T09:54:59Z</dc:date>
    </item>
    <item>
      <title>Re: Time difference DQL</title>
      <link>https://community.dynatrace.com/t5/DQL/Time-difference-DQL/m-p/273013#M1835</link>
      <description>&lt;P&gt;Perhaps something like this would work for you:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;timeseries count = max(appl.completed)
| fieldsAdd minVal = arrayMin(count), maxVal = arrayMax(count)
| fieldsAdd minIndex = arrayLastIndexOf(count, minVal), 
            maxIndex = (arraySize(count) -1) - arrayLastIndexOf(arrayReverse(count), maxVal)
| fieldsAdd timeDistance =(maxIndex - minIndex) * interval&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 19 Mar 2025 23:52:02 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Time-difference-DQL/m-p/273013#M1835</guid>
      <dc:creator>marco_irmer</dc:creator>
      <dc:date>2025-03-19T23:52:02Z</dc:date>
    </item>
  </channel>
</rss>

