<?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: Combine 3 different source type in single table in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Combine-3-different-source-type-in-single-table/m-p/523982#M147841</link>
    <description>&lt;P&gt;if PID is equal to ID (I hope it is, or else you either didn't give us enough information to solve the problem, or the problem is unsolveable because they're not actually related records... &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; )&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(sourcetype=a AND index=foo) OR (sourcetype=b AND index=bar) OR (sourcetype=c)
| eval master_id = case(sourcetype=a, ID, sourcetype=b, PID, sourcetype=c, id)
| stats values(*) as * by master_id&lt;/LI-CODE&gt;&lt;P&gt;You can use, like I did, an eval/case statement to collapse all possible field names that are your ID into one field you can stats on.&lt;/P&gt;&lt;P&gt;Or you could use the coalesce function.&lt;/P&gt;&lt;P&gt;Or a couple of eval/if statements.&lt;/P&gt;&lt;P&gt;And the `stats values(*) as * by ...` is really just shortcut to "doing all the fields". You could replace it with values(field1) as newnameforField1, values(field2) as ...&lt;/P&gt;&lt;P&gt;Or list(field1) as newnameforField1, ...&lt;/P&gt;&lt;P&gt;or any other pile of possibilities.&lt;/P&gt;&lt;P&gt;Anyway.&lt;/P&gt;&lt;P&gt;The idea is just pile them all together, create a new ID that is the same field name for all, then let stats "group" then by that new id field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;happy splunking!&lt;/P&gt;&lt;P&gt;-Rich&lt;/P&gt;</description>
    <pubDate>Fri, 09 Oct 2020 18:56:45 GMT</pubDate>
    <dc:creator>Richfez</dc:creator>
    <dc:date>2020-10-09T18:56:45Z</dc:date>
    <item>
      <title>Combine 3 different source type in single table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combine-3-different-source-type-in-single-table/m-p/523977#M147838</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I want to combine 3 different source type in single table. The column names are different in all the 3 source type to join them.&lt;/P&gt;&lt;P&gt;Eg.&lt;/P&gt;&lt;P&gt;Source type = a&lt;/P&gt;&lt;P&gt;ID name location&lt;/P&gt;&lt;P&gt;Source type = b&lt;/P&gt;&lt;P&gt;PID country&amp;nbsp;&lt;/P&gt;&lt;P&gt;Source type = c&lt;/P&gt;&lt;P&gt;id contact_number&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kindly help to get output as follows:&lt;/P&gt;&lt;P&gt;PID name location country contact_number&lt;/P&gt;&lt;P&gt;There are more than 50 column I want in table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank &amp;amp; Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Oct 2020 18:37:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combine-3-different-source-type-in-single-table/m-p/523977#M147838</guid>
      <dc:creator>ND</dc:creator>
      <dc:date>2020-10-09T18:37:11Z</dc:date>
    </item>
    <item>
      <title>Re: Combine 3 different source type in single table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combine-3-different-source-type-in-single-table/m-p/523982#M147841</link>
      <description>&lt;P&gt;if PID is equal to ID (I hope it is, or else you either didn't give us enough information to solve the problem, or the problem is unsolveable because they're not actually related records... &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; )&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(sourcetype=a AND index=foo) OR (sourcetype=b AND index=bar) OR (sourcetype=c)
| eval master_id = case(sourcetype=a, ID, sourcetype=b, PID, sourcetype=c, id)
| stats values(*) as * by master_id&lt;/LI-CODE&gt;&lt;P&gt;You can use, like I did, an eval/case statement to collapse all possible field names that are your ID into one field you can stats on.&lt;/P&gt;&lt;P&gt;Or you could use the coalesce function.&lt;/P&gt;&lt;P&gt;Or a couple of eval/if statements.&lt;/P&gt;&lt;P&gt;And the `stats values(*) as * by ...` is really just shortcut to "doing all the fields". You could replace it with values(field1) as newnameforField1, values(field2) as ...&lt;/P&gt;&lt;P&gt;Or list(field1) as newnameforField1, ...&lt;/P&gt;&lt;P&gt;or any other pile of possibilities.&lt;/P&gt;&lt;P&gt;Anyway.&lt;/P&gt;&lt;P&gt;The idea is just pile them all together, create a new ID that is the same field name for all, then let stats "group" then by that new id field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;happy splunking!&lt;/P&gt;&lt;P&gt;-Rich&lt;/P&gt;</description>
      <pubDate>Fri, 09 Oct 2020 18:56:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combine-3-different-source-type-in-single-table/m-p/523982#M147841</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2020-10-09T18:56:45Z</dc:date>
    </item>
  </channel>
</rss>

