<?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 Join fields with different field names and stats value? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Join-fields-with-different-field-names-and-stats-value/m-p/679485#M232299</link>
    <description>&lt;P&gt;So, I have one source (transactions) with userNumber and another source (users) with number. I want to join both of them. In each source, they have different field names. I want my table to have the employees name, which in in source users, which I get in my 2nd query in the join separately. Below is my SPL as of now:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=* sourcetype=transaction 
| stats dc(PARENT_ACCOUNT) as transactionMade by POSTDATE, USERNUMBER
| join left=L right=R where L.USERNUMBER=R.NUMBER [search sourcetype=users | stats values(NAME) as Employee by NUMBER]
| table USERNUMBER Employee PARENT_ACCOUNT POSTDATE transactionMade &lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;What is it that I am doing wrong?&lt;/P&gt;</description>
    <pubDate>Mon, 04 Mar 2024 15:07:11 GMT</pubDate>
    <dc:creator>sumarri</dc:creator>
    <dc:date>2024-03-04T15:07:11Z</dc:date>
    <item>
      <title>Join fields with different field names and stats value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-fields-with-different-field-names-and-stats-value/m-p/679485#M232299</link>
      <description>&lt;P&gt;So, I have one source (transactions) with userNumber and another source (users) with number. I want to join both of them. In each source, they have different field names. I want my table to have the employees name, which in in source users, which I get in my 2nd query in the join separately. Below is my SPL as of now:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=* sourcetype=transaction 
| stats dc(PARENT_ACCOUNT) as transactionMade by POSTDATE, USERNUMBER
| join left=L right=R where L.USERNUMBER=R.NUMBER [search sourcetype=users | stats values(NAME) as Employee by NUMBER]
| table USERNUMBER Employee PARENT_ACCOUNT POSTDATE transactionMade &lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;What is it that I am doing wrong?&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2024 15:07:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-fields-with-different-field-names-and-stats-value/m-p/679485#M232299</guid>
      <dc:creator>sumarri</dc:creator>
      <dc:date>2024-03-04T15:07:11Z</dc:date>
    </item>
    <item>
      <title>Re: Join fields with different field names and stats value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-fields-with-different-field-names-and-stats-value/m-p/679487#M232300</link>
      <description>&lt;P&gt;It depends what it is you are trying to do, and what you think is wrong. As it stands, PARENT_ACCOUNT is not a field beyond the stats command (since it isn't listed as an output field - dc just counts the distinct values of the field without listing them).&lt;/P&gt;&lt;P&gt;For the "join", you don't need a join (and they usually should be avoided if possible as they are slow and have limitations). Try something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=* sourcetype=transaction OR sourcetype=users
| eval USERNUMBER=coalesce(USERNUMBER, NUMBER)
| eventstats values(NAME) as Employee by USERNUMBER
| stats dc(PARENT_ACCOUNT) as transactionMade values(Employee) as Employee by POSTDATE, USERNUMBER
| table USERNUMBER Employee PARENT_ACCOUNT POSTDATE transactionMade&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 04 Mar 2024 14:40:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-fields-with-different-field-names-and-stats-value/m-p/679487#M232300</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-03-04T14:40:37Z</dc:date>
    </item>
    <item>
      <title>Re: Join fields with different field names and stats value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-fields-with-different-field-names-and-stats-value/m-p/679489#M232301</link>
      <description>&lt;P&gt;I was not getting any data together, that was what was wrong... sorry for the miscommunication. I implemented your idea, and I am getting data now! Thank you!!!&lt;BR /&gt;&lt;BR /&gt;However, I am not getting the&amp;nbsp;&amp;nbsp;Employee column filled. It might because of the data issue. But, I wanted to know if we can label the fields by source. For example. I have UserNumber in both sources that mean different things and name in both sources that mean different things... How can I help Splunk differentiate them? Is there any resources would you suggest?&lt;BR /&gt;&lt;BR /&gt;Thank you so much!&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2024 14:53:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-fields-with-different-field-names-and-stats-value/m-p/679489#M232301</guid>
      <dc:creator>sumarri</dc:creator>
      <dc:date>2024-03-04T14:53:12Z</dc:date>
    </item>
    <item>
      <title>Re: Join fields with different field names and stats value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-fields-with-different-field-names-and-stats-value/m-p/679586#M232327</link>
      <description>&lt;P&gt;Try something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=* sourcetype=transaction OR sourcetype=users
| eval CommonNumber=if(sourcetype="transaction", USERNUMBER, NUMBER)
| eventstats values(NAME) as Employee by CommonNumber
| stats dc(PARENT_ACCOUNT) as transactionMade values(Employee) as Employee values(USERNUMBER) as USERNUMBER by POSTDATE, CommonNumber
| table CommonNumber USERNUMBER Employee PARENT_ACCOUNT POSTDATE transactionMade&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 05 Mar 2024 13:13:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-fields-with-different-field-names-and-stats-value/m-p/679586#M232327</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-03-05T13:13:56Z</dc:date>
    </item>
  </channel>
</rss>

