<?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: Carry over the value of a field to another result row in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/Carry-over-the-value-of-a-field-to-another-result-row/m-p/268533#M1643</link>
    <description>&lt;P&gt;Would it make sense to summarize the results? If I got your question right, then one of the solutions would be to use takeLast aggregation function for the times and just summarize based on them, e.g.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| summarize {
    start_time = takeLast(start), 
    ack_time = takeLast(ack), 
    end_time = takeLast(end),
    latest_status = takeLast(status)
  }, by: { id, title }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A solution with the demo data that resembles your use-case can be seen in a shared case on our Playground:&amp;nbsp;&lt;A href="https://wkf10640.apps.dynatrace.com/ui/apps/dynatrace.security.investigator/share/2a99bca9-eeb7-4671-804f-1261eb52cbd6" target="_blank"&gt;https://wkf10640.apps.dynatrace.com/ui/apps/dynatrace.security.investigator/share/2a99bca9-eeb7-4671-804f-1261eb52cbd6&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Is this something you had in mind?&lt;/P&gt;</description>
    <pubDate>Tue, 28 Jan 2025 07:32:37 GMT</pubDate>
    <dc:creator>Tiit_Hallas</dc:creator>
    <dc:date>2025-01-28T07:32:37Z</dc:date>
    <item>
      <title>Carry over the value of a field to another result row</title>
      <link>https://community.dynatrace.com/t5/DQL/Carry-over-the-value-of-a-field-to-another-result-row/m-p/268303#M1637</link>
      <description>&lt;P&gt;Hello community,&lt;/P&gt;&lt;P&gt;I have set up a bucket to retrieve events from the "Splunk OnCall" tool in order to create monitoring dashboards. No problem on this side, I receive my data.&lt;/P&gt;&lt;P&gt;I am preparing a dashboard with the listing of OnCall alerts. In order to provide maximum detail, I want to calculate the lifetime of an OnCall alert. And this is where I get stuck because I receive an event for each alert status. I am looking to use the "&lt;STRONG&gt;timestamp&lt;/STRONG&gt;" field to be able to do this calculation, so I started with the idea of ​​having a field with the timestamp value for each state in order to do a basic calculation:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Red_0-1737709178176.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/25936i6C7AA3ED6F940E48/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Red_0-1737709178176.png" alt="Red_0-1737709178176.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I have a problem, I am looking to report the values ​​of these fields on each line of the result of an alert, otherwise, I cannot do the calculation:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Red_1-1737709198135.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/25937i8FB8E23BB9C861FA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Red_1-1737709198135.png" alt="Red_1-1737709198135.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And the additional difficulty is that I must only display the last current state (in the previous screens, I show the 3 possible states to illustrate my problem but at the end, there is a dedup to keep only the last state).&lt;/P&gt;&lt;P&gt;I searched everywhere in the doc but I did not find a solution. Do you have any idea how we can go about it, if it is feasible?&lt;/P&gt;&lt;P&gt;Here is the DQL that I am currently using, it is not yet optimized:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;fetch events
| filter source == "OnCall"
| filterOut in(routingKey, array("dynatrace_event", "mpb-dynatrace_event"))
| sort incidentNumber asc, timestamp desc
//| dedup incidentNumber
| fieldsAdd parse(event, "STRING:priority ' - 'LD")
| fieldsAdd parse(event, """(('P'LD' - 'LD:title)|LD:title)""")
| fieldsAdd priority = if(isNull(priority), "Px", else:priority)
| fieldsAdd routingKey = if(routingKey == "dynatrace_2", "Dynatrace", else:if(routingKey == "servicepilot_prod", "ServicePilot", else:if(routingKey == "control-m", "Control-M", else:if(routingKey == "dynatrace_mfe", "Dynatrace MFE", else:if(routingKey == "control-m_mfe", "Control-M MFE", else:if(routingKey == "dynatrace_amm", "Dynatrace AMM", else:if(routingKey == "control-m_z-os", "Control-M Z/OS", else:if(routingKey == "mpb-control-m", "Control-M MPB", else:if(routingKey == "mpb-dynatrace_problem", "Dynatrace MPB", else:if(routingKey == "dynatrace_f02", "Dynatrace F02", else:routingKey))))))))))

| fieldsAdd startAlert = if(alertType == "CRITICAL", timestamp, else:"")
| fieldsAdd ackAlert = if(alertType == "ACKNOWLEDGEMENT", timestamp, else:"")
| fieldsAdd endAlert = if(alertType == "RECOVERY", timestamp, else:"")

| fieldsRename `Priorité` = priority, `Dernier état` = alertType, `Titre` = title, `N° OnCall` = incidentNumber, `Propriétaire` = owner, `Source` = routingKey, `N° ticket EV` = ticket_EV
| fields timestamp, startAlert, ackAlert, endAlert, `N° OnCall`, `Dernier état`, `Priorité`, Titre, Source, `Propriétaire`, `N° ticket EV`&lt;/LI-CODE&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Sincerely,&lt;/P&gt;&lt;P&gt;Red&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2025 09:01:31 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Carry-over-the-value-of-a-field-to-another-result-row/m-p/268303#M1637</guid>
      <dc:creator>Red</dc:creator>
      <dc:date>2025-01-24T09:01:31Z</dc:date>
    </item>
    <item>
      <title>Re: Carry over the value of a field to another result row</title>
      <link>https://community.dynatrace.com/t5/DQL/Carry-over-the-value-of-a-field-to-another-result-row/m-p/268533#M1643</link>
      <description>&lt;P&gt;Would it make sense to summarize the results? If I got your question right, then one of the solutions would be to use takeLast aggregation function for the times and just summarize based on them, e.g.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| summarize {
    start_time = takeLast(start), 
    ack_time = takeLast(ack), 
    end_time = takeLast(end),
    latest_status = takeLast(status)
  }, by: { id, title }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A solution with the demo data that resembles your use-case can be seen in a shared case on our Playground:&amp;nbsp;&lt;A href="https://wkf10640.apps.dynatrace.com/ui/apps/dynatrace.security.investigator/share/2a99bca9-eeb7-4671-804f-1261eb52cbd6" target="_blank"&gt;https://wkf10640.apps.dynatrace.com/ui/apps/dynatrace.security.investigator/share/2a99bca9-eeb7-4671-804f-1261eb52cbd6&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Is this something you had in mind?&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2025 07:32:37 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Carry-over-the-value-of-a-field-to-another-result-row/m-p/268533#M1643</guid>
      <dc:creator>Tiit_Hallas</dc:creator>
      <dc:date>2025-01-28T07:32:37Z</dc:date>
    </item>
    <item>
      <title>Re: Carry over the value of a field to another result row</title>
      <link>https://community.dynatrace.com/t5/DQL/Carry-over-the-value-of-a-field-to-another-result-row/m-p/268564#M1644</link>
      <description>&lt;P&gt;Hello &lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/56833"&gt;@Tiit_Hallas&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Thanks for your help. I'm not yet comfortable with DQL, I'm still discovering some things (like the "summarize" command). I adapted it slightly to add some necessary fields to my dashboard, and I get everything back as it should:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Red_1-1738059285684.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/26011i32E03471813D986F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Red_1-1738059285684.png" alt="Red_1-1738059285684.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;So, after having validated on a particular alert (this makes the verification more readable), I deactivated the filter so that it applies to all the fields but there, I no longer have the fields filled in:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Red_2-1738059491309.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/26012i31879FB0AB33B308/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Red_2-1738059491309.png" alt="Red_2-1738059491309.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the impression that it only takes the last parameter (in our case, the end_time). I tinkered a little and I saw that by changing the order of the "by" parameter and specifying to sort by the incidentNumber, it worked as well for a targeted element as for the entire dashboard:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Red_3-1738060630396.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/26013i15CB3D69788FBAC6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Red_3-1738060630396.png" alt="Red_3-1738060630396.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again for your help. Have a nice day,&lt;/P&gt;&lt;P&gt;Sincerely,&lt;/P&gt;&lt;P&gt;Red&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2025 10:41:59 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Carry-over-the-value-of-a-field-to-another-result-row/m-p/268564#M1644</guid>
      <dc:creator>Red</dc:creator>
      <dc:date>2025-01-28T10:41:59Z</dc:date>
    </item>
  </channel>
</rss>

