<?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: How to join two searches that have two common fields and put a condition on one of the common fields? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-that-have-two-common-fields-and-put-a/m-p/217234#M63810</link>
    <description>&lt;P&gt;Thanks MuS for your feedback. I will work on this.&lt;BR /&gt;
I need to access _time value from  the event generated. Since _time is present in all events. If I need to access _time from hits-table, how do i do it.&lt;BR /&gt;
I want to compare _time from hits_table such that it should be between logout-time and login_time of user-history to generate a match in addition to ip_address.&lt;BR /&gt;
-Gauri&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 07:53:29 GMT</pubDate>
    <dc:creator>GauriSplunk</dc:creator>
    <dc:date>2020-09-29T07:53:29Z</dc:date>
    <item>
      <title>How to join two searches that have two common fields and put a condition on one of the common fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-that-have-two-common-fields-and-put-a/m-p/217223#M63799</link>
      <description>&lt;P&gt;I want to do a join of two searches that have a common field ID and time, but I want to have a condition on time when IDs match.&lt;BR /&gt;
Consider two tables user-info and some-hits&lt;/P&gt;

&lt;P&gt;user-info&lt;BR /&gt;&lt;BR /&gt;
name   ipaddress    time&lt;BR /&gt;
user1  20.20.20.20   t0&lt;BR /&gt;
user2  20.20.20.20   t1&lt;BR /&gt;
user1  30.30.30.30   t2&lt;/P&gt;

&lt;P&gt;some-hits&lt;BR /&gt;
ipaddress     hits    time&lt;BR /&gt;
20.20.20.20  10       t0.03&lt;BR /&gt;
20.20.20.20   40      t0.03&lt;BR /&gt;
20.20.20.20    46      t0.9&lt;BR /&gt;
30.30.30.30    60      t1&lt;BR /&gt;
30.30.30.30     78     t1.5&lt;/P&gt;

&lt;P&gt;Here I want to match all records from some-hits with user-info whose ipaddress match, but some-hits.time &amp;lt; user-info.time&lt;BR /&gt;
So t0.03 should match with t0 .  t0.9 should  match with   t1.  t1 and t1.5 should match with t2.&lt;/P&gt;

&lt;P&gt;I wanted to know how I can use join to achieve this?&lt;BR /&gt;
Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 02 Nov 2015 19:46:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-that-have-two-common-fields-and-put-a/m-p/217223#M63799</guid>
      <dc:creator>GauriSplunk</dc:creator>
      <dc:date>2015-11-02T19:46:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two searches that have two common fields and put a condition on one of the common fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-that-have-two-common-fields-and-put-a/m-p/217224#M63800</link>
      <description>&lt;P&gt;Hi GauriSplunk,&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;join&lt;/CODE&gt; is the last resort to solve search problems, not the first choice - see docs &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.3.0/SearchReference/Join"&gt;http://docs.splunk.com/Documentation/Splunk/6.3.0/SearchReference/Join&lt;/A&gt; or this &lt;A href="https://answers.splunk.com/answers/129424/how-to-compare-fields-over-multiple-sourcetypes-without-join-append-or-use-of-subsearches.html"&gt;https://answers.splunk.com/answers/129424/how-to-compare-fields-over-multiple-sourcetypes-without-join-append-or-use-of-subsearches.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Your problem here is the value of &lt;CODE&gt;time&lt;/CODE&gt; is not a number, its a string and therefore Splunk will not do what you expect because it will compare it differently. First you need to &lt;EM&gt;remove&lt;/EM&gt; the &lt;CODE&gt;t&lt;/CODE&gt; from the time values and convert it to a numeric value:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; eval time=tonumber(trim(time, "t"))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Next you can get the two &lt;CODE&gt;time&lt;/CODE&gt; values into new field depending on the &lt;CODE&gt;source&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval user_time=tonumber(trim(like(source, "%user-info%"), "t")) | eval some_time=tonumber(trim(like(source, "%some-info%"), "t")) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And finally use the new time fields to compare them:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search here 
| eval user_time=tonumber(trim(like(source, "%user-info%"), "t")) 
| eval some_time=tonumber(trim(like(source, "%some-info%"), "t")) 
| stats count by ipaddress, name, hits, user_time, some_time
| where some_time &amp;lt; user_time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is un-tested so you probably need to tweak it, but it should give you some hints how it can be done.&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Mon, 02 Nov 2015 20:08:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-that-have-two-common-fields-and-put-a/m-p/217224#M63800</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-11-02T20:08:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two searches that have two common fields and put a condition on one of the common fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-that-have-two-common-fields-and-put-a/m-p/217225#M63801</link>
      <description>&lt;P&gt;Thanks for your reply MuS. In my case , both searches have diff index. one of the search is a summary search and the other is a detailed search. The detailed search is my main search (user-info) . The summary search (some-hits) is the second search. &lt;/P&gt;

&lt;P&gt;In the link you sent,  &lt;A href="https://answers.splunk.com/answers/129424/how-to-compare-fields-over-multiple-sourcetypes-without-join-append-or-use-of-subsearches.html"&gt;https://answers.splunk.com/answers/129424/how-to-compare-fields-over-multiple-sourcetypes-without-join-append-or-use-of-subsearches.html&lt;/A&gt;&lt;BR /&gt;
the index is the same but different sourcetypes&lt;/P&gt;

&lt;P&gt;Can I write a query w/o join in this use case?&lt;BR /&gt;
Thanks&lt;BR /&gt;
-Gauri&lt;/P&gt;</description>
      <pubDate>Mon, 02 Nov 2015 21:31:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-that-have-two-common-fields-and-put-a/m-p/217225#M63801</guid>
      <dc:creator>GauriSplunk</dc:creator>
      <dc:date>2015-11-02T21:31:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two searches that have two common fields and put a condition on one of the common fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-that-have-two-common-fields-and-put-a/m-p/217226#M63802</link>
      <description>&lt;P&gt;Hi Gauri,&lt;/P&gt;

&lt;P&gt;it does not matter if your events are in different &lt;CODE&gt;index&lt;/CODE&gt;, &lt;CODE&gt;source&lt;/CODE&gt; or &lt;CODE&gt;sourcetypes&lt;/CODE&gt; you can most likely use &lt;CODE&gt;stats&lt;/CODE&gt; instead of &lt;CODE&gt;join&lt;/CODE&gt; &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;BR /&gt;
Just use as base search something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=a Or index=b sourcetype=c OR sourcetype=d | more Splunk Fu ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Mon, 02 Nov 2015 21:37:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-that-have-two-common-fields-and-put-a/m-p/217226#M63802</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-11-02T21:37:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two searches that have two common fields and put a condition on one of the common fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-that-have-two-common-fields-and-put-a/m-p/217227#M63803</link>
      <description>&lt;P&gt;ok . I will try it. &lt;BR /&gt;
I also need to find the total hits for all  the matched ipaddress and time event.&lt;BR /&gt;
in the example above, I am expecting an output like:&lt;/P&gt;

&lt;P&gt;name    time     ipaddress    #hits&lt;/P&gt;

&lt;P&gt;user1     t0         20.20.20.20   50   (10 + 40)&lt;BR /&gt;
user2     t1          20.20.20.20   46&lt;BR /&gt;
user1    t2           30.30.30.30    138   (60 + 78)&lt;/P&gt;

&lt;P&gt;Can i calculate sum for every matched combination from two search result sets?&lt;/P&gt;</description>
      <pubDate>Mon, 02 Nov 2015 21:59:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-that-have-two-common-fields-and-put-a/m-p/217227#M63803</guid>
      <dc:creator>GauriSplunk</dc:creator>
      <dc:date>2015-11-02T21:59:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two searches that have two common fields and put a condition on one of the common fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-that-have-two-common-fields-and-put-a/m-p/217228#M63804</link>
      <description>&lt;P&gt;For my above example it would be like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search here 
 | eval user_time=tonumber(trim(like(source, "%user-info%"), "t")) 
 | eval some_time=tonumber(trim(like(source, "%some-info%"), "t")) 
 | stats sum(hits) AS total_hits by ipaddress, name, hits, user_time, some_time
 | where some_time &amp;lt; user_time
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Nov 2015 19:23:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-that-have-two-common-fields-and-put-a/m-p/217228#M63804</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-11-03T19:23:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two searches that have two common fields and put a condition on one of the common fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-that-have-two-common-fields-and-put-a/m-p/217229#M63805</link>
      <description>&lt;P&gt;hi MuS,&lt;BR /&gt;
Thanks for your help.&lt;BR /&gt;
I tried to use OR for my base search like u said:&lt;BR /&gt;
(sourcetype=ib:reserved source=ib:user index=ib_security) OR index=ib_summary report=si_hits&lt;/P&gt;

&lt;P&gt;I first just wanted ot try this out to see what events I get.&lt;BR /&gt;
I just get results for the summary search ( index=ib_summary report=si_hits).&lt;BR /&gt;
I do not get any events from first search (ib:user)&lt;/P&gt;

&lt;P&gt;What i am missing here?&lt;BR /&gt;
Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 07:50:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-that-have-two-common-fields-and-put-a/m-p/217229#M63805</guid>
      <dc:creator>GauriSplunk</dc:creator>
      <dc:date>2020-09-29T07:50:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two searches that have two common fields and put a condition on one of the common fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-that-have-two-common-fields-and-put-a/m-p/217230#M63806</link>
      <description>&lt;P&gt;Just to add clarity to your search, what you have is &lt;/P&gt;

&lt;P&gt;(sourcetype=ib:reserved AND source=ib:user AND index=ib_security) OR index=ib_summary AND report=si_hits. In other words, this will match&lt;BR /&gt;&lt;BR /&gt;
(sourcetype=ib:reserved AND source=ib:user AND index=ib_security)  AND report=si_hits&lt;/P&gt;

&lt;P&gt;OR &lt;/P&gt;

&lt;P&gt;(index=ib_summary AND report=si_hits)&lt;/P&gt;

&lt;P&gt;What I think you are looking for is &lt;/P&gt;

&lt;P&gt;(sourcetype=ib:reserved source=ib:user index=ib_security) OR (index=ib_summary report=si_hits)&lt;/P&gt;

&lt;P&gt;where report is a key field only found in the summary index. Give that a shot.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 07:50:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-that-have-two-common-fields-and-put-a/m-p/217230#M63806</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2020-09-29T07:50:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two searches that have two common fields and put a condition on one of the common fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-that-have-two-common-fields-and-put-a/m-p/217231#M63807</link>
      <description>&lt;P&gt;Well run each search seperate and see if you get results back:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; (sourcetype=ib:reserved source=ib:user index=ib_security)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and then &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=ib_summary report=si_hits 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;BTW, as mentioned in your &lt;CODE&gt;earliest=-1w&lt;/CODE&gt; question, you should NOT set &lt;CODE&gt;source&lt;/CODE&gt; in &lt;CODE&gt;inputs.conf&lt;/CODE&gt; see the docs why : &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.3.1/admin/Inputsconf"&gt;http://docs.splunk.com/Documentation/Splunk/6.3.1/admin/Inputsconf&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Nov 2015 19:44:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-that-have-two-common-fields-and-put-a/m-p/217231#M63807</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-11-08T19:44:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two searches that have two common fields and put a condition on one of the common fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-that-have-two-common-fields-and-put-a/m-p/217232#M63808</link>
      <description>&lt;P&gt;Hi MuS,&lt;BR /&gt;
The solution given above does not work for me. I think it was interpreted wrongly.&lt;BR /&gt;
Here is my use case:&lt;/P&gt;

&lt;P&gt;I have search user-history&lt;/P&gt;

&lt;P&gt;username    ipaddress   logintime logout time&lt;BR /&gt;
user1            20.20.20.20     12.00     12.05&lt;BR /&gt;
user2            20.20.20.20      12:10       12:50&lt;BR /&gt;
user1            30.30.30.30       11:40        11:55&lt;/P&gt;

&lt;P&gt;I have another search  hits-table&lt;BR /&gt;
Clientid      hits      time             domain&lt;BR /&gt;
20.20.20.20    2         12:02          fb.com&lt;BR /&gt;
20.20.20.20     3         12:02          fb.com&lt;BR /&gt;
30.30.30.30     5          11:45          boo.com&lt;/P&gt;

&lt;P&gt;In second search I want to first  find total hits by time and domain which gives me&lt;/P&gt;

&lt;P&gt;clientid         total-count         time        domain&lt;BR /&gt;
20.20.20.20     5                      12:02      fb.com&lt;BR /&gt;
30.30.30.30     5                       11:45    boo.com&lt;/P&gt;

&lt;P&gt;Now i want to match the user-history results with this such that my result table should look like&lt;BR /&gt;
Here user2 did not have any  hits in the time it was logged in. So its record will not be in result table.&lt;/P&gt;

&lt;P&gt;The match should be on ipaddress==clientid and time is between logintime and logout time&lt;BR /&gt;
username     ipaddress         #hits     time&lt;/P&gt;

&lt;P&gt;user1             20.,20.20.20       5           _time value from hits-table&lt;BR /&gt;
user1           30.30.30.30          5           _time value from hits-table&lt;/P&gt;

&lt;P&gt;Can this be done without join?&lt;BR /&gt;
What would be the best approach considering the user-history table would be large&lt;/P&gt;

&lt;P&gt;Thanks&lt;BR /&gt;
-Gauri&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2015 18:06:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-that-have-two-common-fields-and-put-a/m-p/217232#M63808</guid>
      <dc:creator>GauriSplunk</dc:creator>
      <dc:date>2015-11-09T18:06:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two searches that have two common fields and put a condition on one of the common fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-that-have-two-common-fields-and-put-a/m-p/217233#M63809</link>
      <description>&lt;P&gt;Hi GauriSplunk,&lt;/P&gt;

&lt;P&gt;after all your feedback here is a new answer, which is tested and working all based on your provided information.&lt;/P&gt;

&lt;P&gt;First create a &lt;CODE&gt;csv&lt;/CODE&gt; file called &lt;CODE&gt;user-history&lt;/CODE&gt; containing:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;username, ipaddress, logintime, logouttime
user1, 20.20.20.20, 12.00, 12.05
user2, 20.20.20.20, 12:10, 12:50
user1, 30.30.30.30, 11:40, 11:55
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;next create a &lt;CODE&gt;csv&lt;/CODE&gt; file called &lt;CODE&gt;hits-table&lt;/CODE&gt; containing:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Clientid, hits, time, domain
20.20.20.20, 2, 12:02, fb.com
20.20.20.20, 3, 12:02, fb.com
30.30.30.30, 5, 11:45, boo.com
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Load them into Splunk using the methods from the docs &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.3.0/Data/Getstartedwithgettingdatain"&gt;http://docs.splunk.com/Documentation/Splunk/6.3.0/Data/Getstartedwithgettingdatain&lt;/A&gt; or us the URI &lt;CODE&gt;&lt;A href="http://YourSplunkServer/en-US/manager/search/adddata" target="test_blank"&gt;http://YourSplunkServer/en-US/manager/search/adddata&lt;/A&gt;&lt;/CODE&gt;. Once the data is indexed use this search to get the result based on your last comment:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="user-history.csv" OR source="hits-table.csv" host="indexer" sourcetype="csv" 
| eval ClientId=coalesce(Clientid,ipaddress) 
| fields ClientId, username, domain, time, hits 
| streamstats values(username) AS user by ClientId 
| stats sum(hits) AS total by user, ClientId, domain, time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me break down this and explain what is happening here:&lt;BR /&gt;
This is the base search which will return all needed fields to get to the result.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="user-history.csv" OR source="hits-table.csv" host="indexer" sourcetype="csv" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Next step is to use either &lt;CODE&gt;Clientid&lt;/CODE&gt; or &lt;CODE&gt;ipaddress&lt;/CODE&gt; as field &lt;CODE&gt;ClientId&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval ClientId=coalesce(Clientid,ipaddress) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now we limit the used fields for the next steps&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| fields ClientId, username, domain, time, hits 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is the most important step for you, because it will map the users to &lt;CODE&gt;ClientId&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| streamstats values(username) AS user by ClientId 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;so it can be used in the final &lt;CODE&gt;stats&lt;/CODE&gt; to get the total hits on a domain by user and time &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats sum(hits) AS total by user, ClientId, domain, time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If this still does not match your requirement, modify it until your done &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Hope this helps and it will be much more efficient then &lt;CODE&gt;join&lt;/CODE&gt; and you will not hit any sub-search limits.&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2015 20:07:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-that-have-two-common-fields-and-put-a/m-p/217233#M63809</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-11-09T20:07:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two searches that have two common fields and put a condition on one of the common fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-that-have-two-common-fields-and-put-a/m-p/217234#M63810</link>
      <description>&lt;P&gt;Thanks MuS for your feedback. I will work on this.&lt;BR /&gt;
I need to access _time value from  the event generated. Since _time is present in all events. If I need to access _time from hits-table, how do i do it.&lt;BR /&gt;
I want to compare _time from hits_table such that it should be between logout-time and login_time of user-history to generate a match in addition to ip_address.&lt;BR /&gt;
-Gauri&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 07:53:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-that-have-two-common-fields-and-put-a/m-p/217234#M63810</guid>
      <dc:creator>GauriSplunk</dc:creator>
      <dc:date>2020-09-29T07:53:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two searches that have two common fields and put a condition on one of the common fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-that-have-two-common-fields-and-put-a/m-p/217235#M63811</link>
      <description>&lt;P&gt;Start working on the provided example, the last step will be a minor one - hint :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| where time &amp;gt; logintime AND time &amp;lt; logouttime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But you have to use a &lt;CODE&gt;convert dur2sec()&lt;/CODE&gt; on all time values to be able to compare them; Splunk does not like for example the &lt;CODE&gt;:&lt;/CODE&gt; in &lt;CODE&gt;logintime&lt;/CODE&gt; or &lt;CODE&gt;time&lt;/CODE&gt; &lt;/P&gt;

&lt;P&gt;You will get there &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2015 21:31:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-that-have-two-common-fields-and-put-a/m-p/217235#M63811</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-11-09T21:31:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two searches that have two common fields and put a condition on one of the common fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-that-have-two-common-fields-and-put-a/m-p/217236#M63812</link>
      <description>&lt;P&gt;I need to access the event generated time which splunk stores in _time field.&lt;BR /&gt;
Since this field is same for hits_table and user_history, how cna i specify that i want to read the _time from hits_table and not user_history.&lt;BR /&gt;
sorry , I am doing this for the first time hence so many questions.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 07:53:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-that-have-two-common-fields-and-put-a/m-p/217236#M63812</guid>
      <dc:creator>GauriSplunk</dc:creator>
      <dc:date>2020-09-29T07:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two searches that have two common fields and put a condition on one of the common fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-that-have-two-common-fields-and-put-a/m-p/217237#M63813</link>
      <description>&lt;P&gt;hint: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ...| eval myTime=if(like(source, "%hits_table.csv"), _time, null())
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;see docs &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.3.1/SearchReference/CommonEvalFunctions"&gt;http://docs.splunk.com/Documentation/Splunk/6.3.1/SearchReference/CommonEvalFunctions&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2015 00:20:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-that-have-two-common-fields-and-put-a/m-p/217237#M63813</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-11-10T00:20:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two searches that have two common fields and put a condition on one of the common fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-that-have-two-common-fields-and-put-a/m-p/217238#M63814</link>
      <description>&lt;P&gt;I created csv files as u suggested :&lt;BR /&gt;
 username, ipaddress, logintime, logouttime&lt;BR /&gt;
 user1, 20.20.20.20, 11/3/2015 12:00:00, 11/3/2015 12:05:00&lt;BR /&gt;
 user2, 20.20.20.20, 11/3/2015 12:10:00, 11/3/2015 12:50:00&lt;BR /&gt;
 user1, 30.30.30.30, 11/3/2015 11:40:00, 11/3/2015 11:55:00&lt;/P&gt;

&lt;P&gt;Clientid, hits, time, domain&lt;BR /&gt;
 20.20.20.20, 2, 11/3/2015 12:02:00, fb.com&lt;BR /&gt;
 20.20.20.20, 3, 11/3/2015 12:02:00, fb.com&lt;BR /&gt;
 30.30.30.30, 5, 11/3/2015 11:45:00, boo.com&lt;/P&gt;

&lt;P&gt;i uploaded them into splunk under index=ib_test_sample&lt;BR /&gt;
This is the query&lt;BR /&gt;
index="ib_test_sample" sourcetype="csv"|eval ClientId=coalesce(Clientid,ipaddress)| fields ClientId, username, domain, time, hits,logintime,logouttime| eval start_time=strptime(logintime, "%m/%d/%Y %H:%M:%S")| eval end_time=strptime(logouttime, "%m/%d/%Y %H:%M:%S") |eval dns_time=strptime(time, "%m/%d/%Y %H:%M:%S")|streamstats values(username) AS user by ClientId|stats sum(hits) AS total by user, ClientId, domain| table user, ClientId, total,dns_time,start_time,end_time&lt;/P&gt;

&lt;P&gt;i havent added time where time is between logintime and logout time  yet sinc e this is not working.&lt;BR /&gt;
The result I get is &lt;/P&gt;

&lt;P&gt;user    ClientId    total   dns_time    start_time  end_time&lt;BR /&gt;
user2   20.20.20.20     5            &lt;/P&gt;

&lt;P&gt;The time fields are not displayed and the result just has 1 entry which is incorrect.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 07:54:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-that-have-two-common-fields-and-put-a/m-p/217238#M63814</guid>
      <dc:creator>GauriSplunk</dc:creator>
      <dc:date>2020-09-29T07:54:28Z</dc:date>
    </item>
  </channel>
</rss>

