<?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 Transpose and aggregate in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Transpose-and-aggregate/m-p/454889#M128692</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;i need help to obtain the below results. From:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;num         has_breached        sla_name
100         false               P1 RES M
100         false               P1 CON M
200         true                 P2 RES M
200         false               P2 CON M
500         true                 P2 CON M
500         true                 P2 CON M
300         true                 P5 RES M
300         false               P5 CON M
999         true                 P1 RES M
999         false               P3 RES M
999         false               P3 CON M
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;All pairs *RES M values in sla_name translated (aggregated) together in sla_response column and&lt;BR /&gt;
all paris *CON M values in sla_name translated (aggregated) together in sla_contract column&lt;/P&gt;

&lt;P&gt;To:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;num         sla_response        sla_contract
100         false              false
200         true                false
500         true                true
300         true                false
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note that object with num 999 has 3 rows, in case of objects with 3 or more rows, is it possible filter out the related rows?&lt;/P&gt;

&lt;P&gt;Thanks,&lt;/P&gt;

&lt;P&gt;L&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 20:35:00 GMT</pubDate>
    <dc:creator>lvbrunello</dc:creator>
    <dc:date>2020-09-29T20:35:00Z</dc:date>
    <item>
      <title>Transpose and aggregate</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Transpose-and-aggregate/m-p/454889#M128692</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;i need help to obtain the below results. From:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;num         has_breached        sla_name
100         false               P1 RES M
100         false               P1 CON M
200         true                 P2 RES M
200         false               P2 CON M
500         true                 P2 CON M
500         true                 P2 CON M
300         true                 P5 RES M
300         false               P5 CON M
999         true                 P1 RES M
999         false               P3 RES M
999         false               P3 CON M
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;All pairs *RES M values in sla_name translated (aggregated) together in sla_response column and&lt;BR /&gt;
all paris *CON M values in sla_name translated (aggregated) together in sla_contract column&lt;/P&gt;

&lt;P&gt;To:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;num         sla_response        sla_contract
100         false              false
200         true                false
500         true                true
300         true                false
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note that object with num 999 has 3 rows, in case of objects with 3 or more rows, is it possible filter out the related rows?&lt;/P&gt;

&lt;P&gt;Thanks,&lt;/P&gt;

&lt;P&gt;L&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:35:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Transpose-and-aggregate/m-p/454889#M128692</guid>
      <dc:creator>lvbrunello</dc:creator>
      <dc:date>2020-09-29T20:35:00Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose and aggregate</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Transpose-and-aggregate/m-p/454890#M128693</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your current search giving field num, has_breached sla_name
| eval sla_name=if(match(sla_name,"RES M"),"sla_response","sla_contract")
| chart values(has_breached) over num by sla_name
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 Jul 2018 14:49:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Transpose-and-aggregate/m-p/454890#M128693</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-07-24T14:49:13Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose and aggregate</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Transpose-and-aggregate/m-p/454891#M128694</link>
      <description>&lt;P&gt;Here is a search using the multisearch command allowing you to only look at numbers with less than 3 entries.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| multisearch 
    [ search index=YOUR_INDEX sourcetype=YOUR_SOURCETYPE sla_name=*RES* 
    | eval sla_response=has_breached] 
    [ search index=YOUR_INDEX sourcetype=YOUR_SOURCETYPE sla_name=*CON* 
    | eval sla_contract=has_breached] 
| stats values(sla_response) as sla_response values(sla_contract) as sla_contract count by num 
| where count &amp;lt; 3 
| table num sla_response sla_contract
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 Jul 2018 15:03:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Transpose-and-aggregate/m-p/454891#M128694</guid>
      <dc:creator>kmorris_splunk</dc:creator>
      <dc:date>2018-07-24T15:03:42Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose and aggregate</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Transpose-and-aggregate/m-p/454892#M128695</link>
      <description>&lt;P&gt;I just realized I misinterpreted how you wanted to handle the case where there were more than 2 entries (999).  In this case, did you want to take just the entries where sla_name were associated:&lt;/P&gt;

&lt;P&gt;999            true                 P1 RES M&lt;BR /&gt;
 999            false                P3 RES M&lt;BR /&gt;
 999            false                P3 CON M&lt;/P&gt;

&lt;P&gt;For example, did you just want the 2 that start with P3?&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jul 2018 15:35:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Transpose-and-aggregate/m-p/454892#M128695</guid>
      <dc:creator>kmorris_splunk</dc:creator>
      <dc:date>2018-07-24T15:35:51Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose and aggregate</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Transpose-and-aggregate/m-p/454893#M128696</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval raw="100:false:P1 RES M:::100:false:P1 CON M:::200:true:P2 RES M:::200:false:P2 CON M:::500:true:P2 CON M:::500:true:P2 CON M:::300:true:P5 RES M:::300:false:P5 CON M:::999:true:P1 RES M:::999:false:P3 RES M:::999:false:P3 CON M"
| makemv delim=":::" raw
| mvexpand raw
| rename raw AS _raw
| rex "^(?&amp;lt;num&amp;gt;[^:]+):(?&amp;lt;has_breached&amp;gt;[^:]+):(?&amp;lt;hsla_name&amp;gt;[^:]+)$"
| table num has_breached hsla_name

| rename COMMENT AS "Everything above generates sample event data; everything below is your solution"

| stats count count(eval(has_breached=="true" AND like(hsla_name, "%RES%"))) AS sla_response count(eval(has_breached=="true" AND like(hsla_name, "%CON%"))) AS sla_contract BY num
| where count &amp;lt; 3
| foreach sla_* [ eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=if(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;==0, "false", "true") ]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 Jul 2018 17:18:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Transpose-and-aggregate/m-p/454893#M128696</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2018-07-24T17:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose and aggregate</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Transpose-and-aggregate/m-p/454894#M128697</link>
      <description>&lt;P&gt;I don't want take in consideration all rows with id 999.&lt;BR /&gt;
Then remove all the rows with a particular id where rows count &amp;gt; 2.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jul 2018 10:24:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Transpose-and-aggregate/m-p/454894#M128697</guid>
      <dc:creator>lvbrunello</dc:creator>
      <dc:date>2018-07-25T10:24:07Z</dc:date>
    </item>
  </channel>
</rss>

