<?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 correlate data without subsearch or transaction in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/correlate-data-without-subsearch-or-transaction/m-p/291533#M162012</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I got data that have some fields missing in some events, e.g.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;field1    field2    field3    field4   field5
  A                            val1
            B        val2
  A         B                             val3
  C                            val5
            D        val4
  C         D                             val6  
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and want to group by either field1 or field2 to make output like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;field1    field2    field3    field4   field5
  A          B        val2      val1    val3
  C          D        val4      val5    val6
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I tried to avoid join, subsearch, or transaction.   Is it possible?&lt;BR /&gt;
Sorry for newbie question.&lt;/P&gt;

&lt;P&gt;Thanks and rgds&lt;BR /&gt;
/st wong&lt;/P&gt;</description>
    <pubDate>Tue, 27 Mar 2018 10:07:46 GMT</pubDate>
    <dc:creator>stwong</dc:creator>
    <dc:date>2018-03-27T10:07:46Z</dc:date>
    <item>
      <title>correlate data without subsearch or transaction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/correlate-data-without-subsearch-or-transaction/m-p/291533#M162012</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I got data that have some fields missing in some events, e.g.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;field1    field2    field3    field4   field5
  A                            val1
            B        val2
  A         B                             val3
  C                            val5
            D        val4
  C         D                             val6  
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and want to group by either field1 or field2 to make output like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;field1    field2    field3    field4   field5
  A          B        val2      val1    val3
  C          D        val4      val5    val6
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I tried to avoid join, subsearch, or transaction.   Is it possible?&lt;BR /&gt;
Sorry for newbie question.&lt;/P&gt;

&lt;P&gt;Thanks and rgds&lt;BR /&gt;
/st wong&lt;/P&gt;</description>
      <pubDate>Tue, 27 Mar 2018 10:07:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/correlate-data-without-subsearch-or-transaction/m-p/291533#M162012</guid>
      <dc:creator>stwong</dc:creator>
      <dc:date>2018-03-27T10:07:46Z</dc:date>
    </item>
    <item>
      <title>Re: correlate data without subsearch or transaction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/correlate-data-without-subsearch-or-transaction/m-p/291534#M162013</link>
      <description>&lt;P&gt;Did you try&lt;CODE&gt;appendcols&lt;/CODE&gt;? Like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;..... | stats values(field3) AS field3 values(field4) AS field4 values(field5) AS field5  by field1 | appendcols [search index="abc_new" sourcetype="csv" | stats values(field3) AS field3 values(field4) AS field4 values(field5) AS field5  by field2] |table field1 field2 field3 field4 field5
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Mar 2018 10:39:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/correlate-data-without-subsearch-or-transaction/m-p/291534#M162013</guid>
      <dc:creator>p_gurav</dc:creator>
      <dc:date>2018-03-27T10:39:20Z</dc:date>
    </item>
    <item>
      <title>Re: correlate data without subsearch or transaction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/correlate-data-without-subsearch-or-transaction/m-p/291535#M162014</link>
      <description>&lt;P&gt;Thanks, but can appendcols do something like following?&lt;/P&gt;

&lt;P&gt;..| stats values(field3) as field3, values(field4) as field4, values(field5) as field5 by "either field1 or field2" ?&lt;/P&gt;

&lt;P&gt;and also hope to avoid subsearches.&lt;/P&gt;

&lt;P&gt;Thanks and rgds&lt;/P&gt;</description>
      <pubDate>Tue, 27 Mar 2018 12:21:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/correlate-data-without-subsearch-or-transaction/m-p/291535#M162014</guid>
      <dc:creator>stwong</dc:creator>
      <dc:date>2018-03-27T12:21:43Z</dc:date>
    </item>
    <item>
      <title>Re: correlate data without subsearch or transaction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/correlate-data-without-subsearch-or-transaction/m-p/291536#M162015</link>
      <description>&lt;P&gt;I'd approach this by using eventstats before stats, given the data you presented. &lt;/P&gt;

&lt;P&gt;First, cross-apply the values from field1 and field2:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eventstats values(field1) AS field1 BY field2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This should take your first table and make it look like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; field1    field2    field3    field4   field5
   A                            val1
   A         B        val2
   A         B                             val3
   C                            val5
   C         D        val4
   C         D                             val6  
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now every row in the table has a value for &lt;CODE&gt;field1&lt;/CODE&gt;, making it possible to use stats to populate the table:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats values(field2) AS field2 values(field3) AS field3 values(field4) AS field4 values(field5) AS field5 BY field1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If that doesn't work, it means the table likely has some instances where there is no value for field1, like maybe this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  field1    field2    field3    field4   field5
    A                            val1
    A         B        val2
    A         B                             val3
    C                            val5
    C         D        val4
    C         D                             val6
              E                             val7
              E                  val8
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If your data has events like that, I can help you adjust your search. It'll be a little more complex, but it's still doable.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Mar 2018 13:33:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/correlate-data-without-subsearch-or-transaction/m-p/291536#M162015</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2018-03-27T13:33:01Z</dc:date>
    </item>
    <item>
      <title>Re: correlate data without subsearch or transaction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/correlate-data-without-subsearch-or-transaction/m-p/291537#M162016</link>
      <description>&lt;P&gt;Hi, it works perfectly.  Thanks a lot.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Mar 2018 09:51:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/correlate-data-without-subsearch-or-transaction/m-p/291537#M162016</guid>
      <dc:creator>stwong</dc:creator>
      <dc:date>2018-03-28T09:51:13Z</dc:date>
    </item>
  </channel>
</rss>

