<?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 in Splunk in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Join-in-Splunk/m-p/353932#M104751</link>
    <description>&lt;P&gt;you can use &lt;CODE&gt;append&lt;/CODE&gt; to join both the tables&lt;/P&gt;

&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/7.0.2/SearchReference/Append"&gt;https://docs.splunk.com/Documentation/Splunk/7.0.2/SearchReference/Append&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 19 Mar 2018 11:00:10 GMT</pubDate>
    <dc:creator>bangalorep</dc:creator>
    <dc:date>2018-03-19T11:00:10Z</dc:date>
    <item>
      <title>Join in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-in-Splunk/m-p/353924#M104743</link>
      <description>&lt;P&gt;Hi there!&lt;/P&gt;

&lt;P&gt;Just want to ask if possible to execute a non-equijoin in Splunk? A non-equijoin (in SQL) joins two table using non-equal operator such as &amp;lt;, &amp;gt;, BETWEEN-AND etc.&lt;/P&gt;

&lt;P&gt;I have two tables:&lt;/P&gt;

&lt;P&gt;Employees&lt;BR /&gt;
Staff ID | Log-in | Log-out | Location&lt;BR /&gt;
1001 | 12-30-2017 11:30:00 | 12-30-2017 23:30:00 | LDP1&lt;BR /&gt;
1002 | 12-30-2017 12:30:00 | 12-30-2017 20:30:00 | LDP3&lt;/P&gt;

&lt;P&gt;Sales&lt;BR /&gt;
Txn Date Time | Location | Txn Type&lt;BR /&gt;
12-30-2017 11:48:17 | LDP1 | Sale&lt;/P&gt;

&lt;P&gt;I want to count the number of transactions done by each staff based on their location, log-in and log-out time&lt;/P&gt;

&lt;P&gt;Example:&lt;BR /&gt;
Staff ID | Date |Location | Count of Txns&lt;BR /&gt;
1 | 12-30-2017 | LDP 1 | 345&lt;BR /&gt;
2 | 12-30-2017 | LDP 2 | 416&lt;/P&gt;

&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Mar 2018 03:18:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-in-Splunk/m-p/353924#M104743</guid>
      <dc:creator>cx233alvin</dc:creator>
      <dc:date>2018-03-15T03:18:44Z</dc:date>
    </item>
    <item>
      <title>Re: Join in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-in-Splunk/m-p/353925#M104744</link>
      <description>&lt;P&gt;Hello! Is all the data in one index? Or are they spread across multiple?&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 04:29:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-in-Splunk/m-p/353925#M104744</guid>
      <dc:creator>bangalorep</dc:creator>
      <dc:date>2018-03-19T04:29:48Z</dc:date>
    </item>
    <item>
      <title>Re: Join in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-in-Splunk/m-p/353926#M104745</link>
      <description>&lt;P&gt;They are from 2 different indices.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 04:35:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-in-Splunk/m-p/353926#M104745</guid>
      <dc:creator>cx233alvin</dc:creator>
      <dc:date>2018-03-19T04:35:20Z</dc:date>
    </item>
    <item>
      <title>Re: Join in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-in-Splunk/m-p/353927#M104746</link>
      <description>&lt;P&gt;How do you know which employee made which sale? Is it possible to have 2 employees at the same location at the same time?&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 05:30:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-in-Splunk/m-p/353927#M104746</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2018-03-19T05:30:11Z</dc:date>
    </item>
    <item>
      <title>Re: Join in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-in-Splunk/m-p/353928#M104747</link>
      <description>&lt;P&gt;You can determine which employee performed the sale if:&lt;BR /&gt;
a. the date and timestamp of sale is within the log-in and logout of employee; AND&lt;BR /&gt;
b. the location of sale is equal to location of employee.&lt;/P&gt;

&lt;P&gt;No. there is only one employee assigned at specific time and location. It is not possible to attribute 1 sale to multiple employees.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 06:00:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-in-Splunk/m-p/353928#M104747</guid>
      <dc:creator>cx233alvin</dc:creator>
      <dc:date>2018-03-19T06:00:27Z</dc:date>
    </item>
    <item>
      <title>Re: Join in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-in-Splunk/m-p/353929#M104748</link>
      <description>&lt;P&gt;@cx233alvin, since Location is the correlating field between employee and sale (because Staff-ID is missing in sale). If per location you can find up to 100 StaffID who made the sale, you can try the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; (index="sales" AND Txn-Type=Sale) OR (index="employee")
| stats list(Staff-ID) as Staff-ID list(Log-in) as Log-in list(Log-out) as Log-out list(Txn-Date-Time) as Txn-Date-Time values(index) as index by Location
| search index="employee" index="sales"
| eval data=mvzip('Staff-ID',mvzip('Log-in',mvzip('Log-out','Txn-Date-Time')))
| fields - "Staff-ID" "Log-in" "Log-out" "Txn-Date-Time"
| mvexpand data
| eval data=split(data,",")
| eval "Staff-ID"=mvindex(data,0), "Log-in"=mvindex(data,1), "Log-out"=mvindex(data,2), "Txn-Date-Time"=mvindex(data,3)
| fields - data
| eval Log-in=strptime('Log-in',"%m-%d-%Y%H:%M:%S"), Log-out=strptime('Log-out',"%m-%d-%Y%H:%M:%S"), Txn-Date-Time=strptime('Txn-Date-Time',"%m-%d-%Y%H:%M:%S")
| where 'Log-in'&amp;lt;='Txn-Date-Time' AND 'Txn-Date-Time'&amp;lt;='Log-out'
| fieldformat "Log-in"=strftime('Log-in',"%m-%d-%Y %H:%M:%S")
| fieldformat "Log-out"=strftime('Log-out',"%m-%d-%Y %H:%M:%S")
| fieldformat "Txn-Date-Time"=strftime('Txn-Date-Time',"%m-%d-%Y %H:%M:%S")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Mar 2018 06:05:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-in-Splunk/m-p/353929#M104748</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-03-19T06:05:57Z</dc:date>
    </item>
    <item>
      <title>Re: Join in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-in-Splunk/m-p/353930#M104749</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index="sales" AND Txn-Type=Sale) OR (index="employee")
| eval timestamp =strptime( if(index="employee",'Log-in','Txn-Date-Time'),"%d-%m-%Y %H:%M:%S")
| sort Location "Staff-ID" timestamp index
| streamstats current=f reset_on_change=t 
        last("Staff-ID") as employee last("Log-in") as login last("Log-out") as logout by location "Staff-ID"
| eval login=strptime(login,"%d-%m-%Y %H:%M:%S")
| eval logout=strptime(logout,"%d-%m-%Y %H:%M:%S")
| where index="sales" and timestamp &amp;gt;= login and timestamp &amp;lt;= logout
| eval Date=strftime(timestamp,"%x"
| stats count as "Count of Txns" by employee date Location
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You may need to play around with streamstats command to get this to work as you want. I didn't have any test data to verify that this will work.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 07:14:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-in-Splunk/m-p/353930#M104749</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2018-03-19T07:14:05Z</dc:date>
    </item>
    <item>
      <title>Re: Join in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-in-Splunk/m-p/353931#M104750</link>
      <description>&lt;P&gt;@lguinn [Splunk], just FYI, following is the query I used to mock up data for my SPL above in comment. I have not posted mine as answer because it will work for first 100 match per location.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval employee="1001 | 12-30-2017 11:30:00 | 12-30-2017 23:30:00 | LDP1;1002 | 12-30-2017 12:30:00 | 12-30-2017 13:30:00 | LDP1;1003 | 12-30-2017 22:30:00 | 12-30-2017 23:30:00 | LDP2"
| makemv employee delim=";"
| mvexpand employee
| eval employee=replace(employee," ","")
| makemv employee delim="|"
| eval Staff-ID=mvindex(employee,0),Log-in=mvindex(employee,1),Log-out=mvindex(employee,2),Location=mvindex(employee,3)
| fields Staff-ID, Log-in,Log-out,Location
| eval _time=strptime('Log-in',"%m-%d-%Y%H:%M:%S")
| eval index="employee"
| append [| makeresults
| eval sales="12-30-2017 11:48:17 | LDP1 | Sale;12-30-2017 13:48:17 | LDP1 | Sale"
| makemv sales delim=";"
| mvexpand sales
| eval sales=replace(sales," ","")
| makemv sales delim="|"
| eval Txn-Date-Time=mvindex(sales,0),Location=mvindex(sales,1),Txn-Type=mvindex(sales,2)
| fields Txn-Date-Time,Location,Txn-Type
| eval _time=strptime('Txn-Date-Time',"%m-%d-%Y%H:%M:%S")
| eval index="sales"]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Mar 2018 07:43:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-in-Splunk/m-p/353931#M104750</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-03-19T07:43:35Z</dc:date>
    </item>
    <item>
      <title>Re: Join in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-in-Splunk/m-p/353932#M104751</link>
      <description>&lt;P&gt;you can use &lt;CODE&gt;append&lt;/CODE&gt; to join both the tables&lt;/P&gt;

&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/7.0.2/SearchReference/Append"&gt;https://docs.splunk.com/Documentation/Splunk/7.0.2/SearchReference/Append&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 11:00:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-in-Splunk/m-p/353932#M104751</guid>
      <dc:creator>bangalorep</dc:creator>
      <dc:date>2018-03-19T11:00:10Z</dc:date>
    </item>
    <item>
      <title>Re: Join in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-in-Splunk/m-p/353933#M104752</link>
      <description>&lt;P&gt;Thanks @niketnilay and @lguinn for your replies. I was able to do it based on your suggestions.&lt;/P&gt;

&lt;P&gt;Similar to @lguinn, I just sorted the rows by location and loginTime/ txnDateTime. Then, I used streamstats to get the last login, logout and employeeID. I used eval to check whether the sale transaction is within the login and logout time (set 1 if yes, otherwise 0). Finally, I used sum to get the total number of transactions per teller.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Apr 2018 06:14:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-in-Splunk/m-p/353933#M104752</guid>
      <dc:creator>cx233alvin</dc:creator>
      <dc:date>2018-04-02T06:14:23Z</dc:date>
    </item>
  </channel>
</rss>

