<?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: Join two datasets (main search and subsearch), keep all keys in both, and update non-key fields with data from the subsearch in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Join-two-datasets-main-search-and-subsearch-keep-all-keys-in/m-p/453886#M128442</link>
    <description>&lt;P&gt;Assuming both searches have the field "key" and "data" you could go like this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your_main_search&amp;gt; | rename data as data1 | join type=outer max=0 key [&amp;lt;your_second_search&amp;gt; | rename data as data2] | eval data=coalesce(data2, data1) | table key data
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 21 Mar 2019 15:17:32 GMT</pubDate>
    <dc:creator>DMohn</dc:creator>
    <dc:date>2019-03-21T15:17:32Z</dc:date>
    <item>
      <title>Join two datasets (main search and subsearch), keep all keys in both, and update non-key fields with data from the subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-two-datasets-main-search-and-subsearch-keep-all-keys-in/m-p/453885#M128441</link>
      <description>&lt;P&gt;If I have two searches, one generates fields "key A" and "Column A" and the second search generates fields "key B" "Column B" and I want to join them together, keep all keys in "key A" and update the values that exist in key A AND key B with the values in Column B, leaving column A values as a fallback for keys that don't appear in column B, how would I do that? &lt;BR /&gt;
&lt;CODE&gt;|key| data|   |key|data |&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;|---|---|---|---|---|&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;| A   | 123      |   | A   | 456      |&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;| B   | 123      |   | B   | 456      |&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;| C   | 123      |   | C   | NULL     |&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;| D   | 123      |   | G   | 456      |&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;| E   | 123      |   | H   | 456      |&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;| F   | 123      |   | I   | 123      |&lt;/CODE&gt;&lt;BR /&gt;
||&lt;BR /&gt;
V&lt;BR /&gt;
&lt;CODE&gt;|key | data|&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;|---|---|&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;| A   | 456      |&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;| B   | 456      |&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;| C   | 123      |&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;| D   | 123      |&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;| E   | 123      |&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;| F   | 123      |&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;| G   | 456      |&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;| H   | 456      |&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;| I   | 123      |&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I tried main search | join type=outer max=0 [| subsearch] but it doesn't appear to be working because when I tried &lt;BR /&gt;
main search NOT key=A [| subsearch] I would expect A to be removed from the A search but replaced with B search, but that didn't happen, so I think I'm losing values from the B search.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2019 13:37:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-two-datasets-main-search-and-subsearch-keep-all-keys-in/m-p/453885#M128441</guid>
      <dc:creator>cdhippen</dc:creator>
      <dc:date>2019-03-21T13:37:14Z</dc:date>
    </item>
    <item>
      <title>Re: Join two datasets (main search and subsearch), keep all keys in both, and update non-key fields with data from the subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-two-datasets-main-search-and-subsearch-keep-all-keys-in/m-p/453886#M128442</link>
      <description>&lt;P&gt;Assuming both searches have the field "key" and "data" you could go like this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your_main_search&amp;gt; | rename data as data1 | join type=outer max=0 key [&amp;lt;your_second_search&amp;gt; | rename data as data2] | eval data=coalesce(data2, data1) | table key data
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Mar 2019 15:17:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-two-datasets-main-search-and-subsearch-keep-all-keys-in/m-p/453886#M128442</guid>
      <dc:creator>DMohn</dc:creator>
      <dc:date>2019-03-21T15:17:32Z</dc:date>
    </item>
    <item>
      <title>Re: Join two datasets (main search and subsearch), keep all keys in both, and update non-key fields with data from the subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-two-datasets-main-search-and-subsearch-keep-all-keys-in/m-p/453887#M128443</link>
      <description>&lt;P&gt;This isn't working for me. If I limit the data of the main search (for testing) by saying | inputlookup x-x WHERE key=A and the subsearch results in key=A, key=B, key=C etc, the end result still only returns key=A. I need a way to keep all the results from both searches.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2019 18:14:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-two-datasets-main-search-and-subsearch-keep-all-keys-in/m-p/453887#M128443</guid>
      <dc:creator>cdhippen</dc:creator>
      <dc:date>2019-03-21T18:14:26Z</dc:date>
    </item>
    <item>
      <title>Re: Join two datasets (main search and subsearch), keep all keys in both, and update non-key fields with data from the subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-two-datasets-main-search-and-subsearch-keep-all-keys-in/m-p/453888#M128444</link>
      <description>&lt;P&gt;Ah, right ... You can't join a key where there is none on the left side of the join. Try it that way:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup first_lookup | remane data as data1 | append [| inputlookup second_lookup | rename data as data2] | stats values(data1) as data1, values(data2) as data2 by key | eval data=coalesce(data2,data1) | table key data
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Mar 2019 07:30:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-two-datasets-main-search-and-subsearch-keep-all-keys-in/m-p/453888#M128444</guid>
      <dc:creator>DMohn</dc:creator>
      <dc:date>2019-03-22T07:30:29Z</dc:date>
    </item>
    <item>
      <title>Re: Join two datasets (main search and subsearch), keep all keys in both, and update non-key fields with data from the subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-two-datasets-main-search-and-subsearch-keep-all-keys-in/m-p/453889#M128445</link>
      <description>&lt;P&gt;I forgot to reply that I figured it out, but your solution here is more or less what I did in my search. Thanks for the ideas! The coalesce idea was very valuable.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2019 10:12:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-two-datasets-main-search-and-subsearch-keep-all-keys-in/m-p/453889#M128445</guid>
      <dc:creator>cdhippen</dc:creator>
      <dc:date>2019-03-22T10:12:06Z</dc:date>
    </item>
  </channel>
</rss>

