<?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 DQL: How can I convert row values to column headings in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/DQL-How-can-I-convert-row-values-to-column-headings/m-p/254778#M1166</link>
    <description>&lt;P&gt;I have some DQL that looks at a web servers log files and counts the number of hits on services gives me data in a table like this:&amp;nbsp;&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;service_name&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;status_code&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;hit_count&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;checkOut&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;200&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;1234&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;checkOut&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;404&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would prefer to present it like this so that I can apply percentage calculations and categorise the record as being OK or needing action.&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;service_name&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;200&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;404&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;checkOut&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;1234&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;Is there a way to do this kind of thing?&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 04 Sep 2024 06:04:35 GMT</pubDate>
    <dc:creator>HeadScratcher</dc:creator>
    <dc:date>2024-09-04T06:04:35Z</dc:date>
    <item>
      <title>DQL: How can I convert row values to column headings</title>
      <link>https://community.dynatrace.com/t5/DQL/DQL-How-can-I-convert-row-values-to-column-headings/m-p/254778#M1166</link>
      <description>&lt;P&gt;I have some DQL that looks at a web servers log files and counts the number of hits on services gives me data in a table like this:&amp;nbsp;&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;service_name&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;status_code&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;hit_count&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;checkOut&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;200&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;1234&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;checkOut&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;404&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would prefer to present it like this so that I can apply percentage calculations and categorise the record as being OK or needing action.&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;service_name&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;200&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;404&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;checkOut&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;1234&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;Is there a way to do this kind of thing?&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2024 06:04:35 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/DQL-How-can-I-convert-row-values-to-column-headings/m-p/254778#M1166</guid>
      <dc:creator>HeadScratcher</dc:creator>
      <dc:date>2024-09-04T06:04:35Z</dc:date>
    </item>
    <item>
      <title>Re: DQL: How can I convert row values to column headings</title>
      <link>https://community.dynatrace.com/t5/DQL/DQL-How-can-I-convert-row-values-to-column-headings/m-p/254939#M1175</link>
      <description>&lt;P&gt;Unfortunately the only technique I know to get it is via same method you probably saw already:&lt;BR /&gt;&lt;A href="https://community.dynatrace.com/t5/DQL/DQL-How-to-Flatten-an-Array/m-p/251125/highlight/true#M1073" target="_blank"&gt;https://community.dynatrace.com/t5/DQL/DQL-How-to-Flatten-an-Array/m-p/251125/highlight/true#M1073&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;For your data it would look like:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;data 
  record(serviceName="checkOut", status_code=200, hit_count=1234),
  record(serviceName="checkOut", status_code=404, hit_count=1),
  record(serviceName="login", status_code=200, hit_count=4),
  record(serviceName="login", status_code=403, hit_count=1)
| summarize { d=collectArray(array(toString(status_code),hit_count)) }, by: {serviceName}
| fieldsAdd d=toString(d)
| parse d, "'[' KVP{ '[' DQS:key ', ' LONG:value ']' ', '?}:code ']'"
| fieldsFlatten code
| fieldsRemove d, code&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-1725454213375.png" style="width: 847px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/22199iBE744052FAB86F9A/image-dimensions/847x286?v=v2" width="847" height="286" role="button" title="krzysztof_hoja_0-1725454213375.png" alt="krzysztof_hoja_0-1725454213375.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kris&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2024 12:52:16 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/DQL-How-can-I-convert-row-values-to-column-headings/m-p/254939#M1175</guid>
      <dc:creator>krzysztof_hoja</dc:creator>
      <dc:date>2024-09-04T12:52:16Z</dc:date>
    </item>
    <item>
      <title>Re: DQL: How can I convert row values to column headings</title>
      <link>https://community.dynatrace.com/t5/DQL/DQL-How-can-I-convert-row-values-to-column-headings/m-p/254956#M1176</link>
      <description>&lt;P&gt;Thanks Kris, you are right I did read the other thread.&amp;nbsp; &amp;nbsp;This approach does work fine and is actually quite similar to how I would have approached in in SPL which is where my skillset is coming from.&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2024 15:10:54 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/DQL-How-can-I-convert-row-values-to-column-headings/m-p/254956#M1176</guid>
      <dc:creator>HeadScratcher</dc:creator>
      <dc:date>2024-09-04T15:10:54Z</dc:date>
    </item>
  </channel>
</rss>

