<?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: Question regarding join in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Question-regarding-join/m-p/193730#M55828</link>
    <description>&lt;P&gt;Ok the issue was my Action was nested and the eval didnt like that .... so &lt;BR /&gt;
stats count(eval(body.ACTION="shop")) would not work&lt;BR /&gt;
I renamed body.ACTION to ACTION&lt;BR /&gt;
and changed my query to &lt;BR /&gt;
count(eval(ACTION="shop")) &lt;BR /&gt;
and it now works great. Thanks for all your help!!&lt;/P&gt;</description>
    <pubDate>Tue, 24 Mar 2015 16:26:56 GMT</pubDate>
    <dc:creator>therockhead</dc:creator>
    <dc:date>2015-03-24T16:26:56Z</dc:date>
    <item>
      <title>Question regarding join</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Question-regarding-join/m-p/193716#M55814</link>
      <description>&lt;P&gt;Beginner here, I'm trying to do the following in one query &lt;BR /&gt;
1) Get all unique users  and the count of users &lt;BR /&gt;
2) Using  all the unique users from query 1, search  for who has done action "shop"&lt;BR /&gt;
3)  Show  % of people who did the action  "shop" &lt;/P&gt;

&lt;P&gt;This is what i have tried so far ..&lt;/P&gt;

&lt;P&gt;sourceTag=test index=test | stats dc(user_id) AS "Total Users" | JOIN user_id [search sourceTag=test index=test ACTION="shop" | stats dc(user_id) AS "Shoppers Users" ] | eval PercentageOfUsers=round(tonumber('Shopper Users') * 100 / tonumber('Total Users'))&lt;/P&gt;

&lt;P&gt;Any ideas whats wrong?&lt;BR /&gt;
Thanks,&lt;BR /&gt;
Bill&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 19:16:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Question-regarding-join/m-p/193716#M55814</guid>
      <dc:creator>therockhead</dc:creator>
      <dc:date>2020-09-28T19:16:55Z</dc:date>
    </item>
    <item>
      <title>Re: Question regarding join</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Question-regarding-join/m-p/193717#M55815</link>
      <description>&lt;P&gt;Yes, your first command is only going to return a number of distinct user_ids. This means that you no longer have user_id to join on, since the output of your stats command is just a number. Same for the output of your JOIN command. The output is a number, so there are no user_id field values to join on.&lt;/P&gt;

&lt;P&gt;Does this work for you?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourceTag=test index=test 
| table user_id 
| dedup user_id 
| JOIN user_id [search sourceTag=test index=test ACTION="shop" | table user_id] 
| fillnull 
| stats count(eval(ACTION="shop")) as ShopperCount, count(eval(ACTION!="shop")) as NonShoppers
| eval TotalUsers=ShopperCount+NonShoppers
| eval PercentageOfUsers=round(ShopperCount/TotalUsers*100,2)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can also add renames at the end to give the fields your desired labels. i.e.&lt;BR /&gt;
    | rename PercentageOfUsers as "% of Users that Shopped"&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 19:20:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Question-regarding-join/m-p/193717#M55815</guid>
      <dc:creator>masonmorales</dc:creator>
      <dc:date>2020-09-28T19:20:07Z</dc:date>
    </item>
    <item>
      <title>Re: Question regarding join</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Question-regarding-join/m-p/193718#M55816</link>
      <description>&lt;P&gt;Thanks for response but it did not work for me.  The join is only returning the user_id and no action data so that stats always return 0.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2015 14:34:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Question-regarding-join/m-p/193718#M55816</guid>
      <dc:creator>therockhead</dc:creator>
      <dc:date>2015-03-24T14:34:45Z</dc:date>
    </item>
    <item>
      <title>Re: Question regarding join</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Question-regarding-join/m-p/193719#M55817</link>
      <description>&lt;P&gt;Any chance you could post a few lines of sample data from each source? (Feel free to anonymize field data)&lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2015 14:42:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Question-regarding-join/m-p/193719#M55817</guid>
      <dc:creator>masonmorales</dc:creator>
      <dc:date>2015-03-24T14:42:21Z</dc:date>
    </item>
    <item>
      <title>Re: Question regarding join</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Question-regarding-join/m-p/193720#M55818</link>
      <description>&lt;P&gt;Sure .. for example here are two separate events &lt;/P&gt;

&lt;P&gt;message: { &lt;BR /&gt;
     context: { &lt;BR /&gt;
       user_id: 443d5c6c-32ad-460e-a387-b077e9c47f3f &lt;BR /&gt;
       ....&lt;BR /&gt;
     } &lt;BR /&gt;
     time: 2015-03-24T14:51:58.721Z &lt;BR /&gt;
     action: shop &lt;BR /&gt;
   } &lt;/P&gt;

&lt;P&gt;message: { &lt;BR /&gt;
     context: { &lt;BR /&gt;
       user_id: 443d5c6c-32ad-460e-a387-b077e9c47f3f &lt;BR /&gt;
       .....&lt;BR /&gt;
     } &lt;BR /&gt;
     time: 2015-03-24T14:51:58.721Z &lt;BR /&gt;
     action: login &lt;BR /&gt;
   } &lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2015 14:59:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Question-regarding-join/m-p/193720#M55818</guid>
      <dc:creator>therockhead</dc:creator>
      <dc:date>2015-03-24T14:59:19Z</dc:date>
    </item>
    <item>
      <title>Re: Question regarding join</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Question-regarding-join/m-p/193721#M55819</link>
      <description>&lt;P&gt;Okay, sorry about that. Try this instead:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; sourceTag=test index=test 
 | table user_id 
 | dedup user_id
 | JOIN user_id type=outer [search sourceTag=test index=test ACTION="shop" | table user_id ACTION] 
 | fillnull value=NULL ACTION 
 | stats count(eval(ACTION="shop")) as ShopperCount, count(eval(ACTION!="shop")) as NonShopperCount
 | eval TotalUsers=ShopperCount+NonShopperCount
 | eval PercentageOfUsers=round(ShopperCount/TotalUsers*100,2)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 Mar 2015 15:23:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Question-regarding-join/m-p/193721#M55819</guid>
      <dc:creator>masonmorales</dc:creator>
      <dc:date>2015-03-24T15:23:33Z</dc:date>
    </item>
    <item>
      <title>Re: Question regarding join</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Question-regarding-join/m-p/193722#M55820</link>
      <description>&lt;P&gt;If this worked for you, please click "Accept Answer"&lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2015 15:36:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Question-regarding-join/m-p/193722#M55820</guid>
      <dc:creator>masonmorales</dc:creator>
      <dc:date>2015-03-24T15:36:28Z</dc:date>
    </item>
    <item>
      <title>Re: Question regarding join</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Question-regarding-join/m-p/193723#M55821</link>
      <description>&lt;P&gt;Just trying it out now .. its looking better, the join is returning data that looks correct but the stats is not working.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2015 15:44:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Question-regarding-join/m-p/193723#M55821</guid>
      <dc:creator>therockhead</dc:creator>
      <dc:date>2015-03-24T15:44:59Z</dc:date>
    </item>
    <item>
      <title>Re: Question regarding join</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Question-regarding-join/m-p/193724#M55822</link>
      <description>&lt;P&gt;Could you provide more detail on the behavior you are seeing with stats please? &lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2015 15:53:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Question-regarding-join/m-p/193724#M55822</guid>
      <dc:creator>masonmorales</dc:creator>
      <dc:date>2015-03-24T15:53:14Z</dc:date>
    </item>
    <item>
      <title>Re: Question regarding join</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Question-regarding-join/m-p/193725#M55823</link>
      <description>&lt;P&gt;So if it dont include stats the data format looks correct. If it add the following for example - stats count(eval(ACTION="shop")) as ShopperCount the result will be 0&lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2015 15:55:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Question-regarding-join/m-p/193725#M55823</guid>
      <dc:creator>therockhead</dc:creator>
      <dc:date>2015-03-24T15:55:57Z</dc:date>
    </item>
    <item>
      <title>Re: Question regarding join</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Question-regarding-join/m-p/193726#M55824</link>
      <description>&lt;P&gt;Also count(eval(ACTION!="shop")) as NonShopperCount returns 0 as well.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2015 15:57:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Question-regarding-join/m-p/193726#M55824</guid>
      <dc:creator>therockhead</dc:creator>
      <dc:date>2015-03-24T15:57:06Z</dc:date>
    </item>
    <item>
      <title>Re: Question regarding join</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Question-regarding-join/m-p/193727#M55825</link>
      <description>&lt;P&gt;Also tried with extra equals - stats count(eval(ACTION=="shop")) &lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2015 15:59:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Question-regarding-join/m-p/193727#M55825</guid>
      <dc:creator>therockhead</dc:creator>
      <dc:date>2015-03-24T15:59:41Z</dc:date>
    </item>
    <item>
      <title>Re: Question regarding join</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Question-regarding-join/m-p/193728#M55826</link>
      <description>&lt;P&gt;I extracted ACTION in my test environment with your data and it worked fine. I am guessing you have a different field name for ACTION than what was posted, or that it's not all uppercase. Field names are case sensitive. Could you please verify that the case/spelling of your extracted field for "ACTION" matches that of the example? If it does not, replace all occurrences of "ACTION" in my example with exactly how the "action" field name appears in your environment.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2015 16:01:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Question-regarding-join/m-p/193728#M55826</guid>
      <dc:creator>masonmorales</dc:creator>
      <dc:date>2015-03-24T16:01:54Z</dc:date>
    </item>
    <item>
      <title>Re: Question regarding join</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Question-regarding-join/m-p/193729#M55827</link>
      <description>&lt;P&gt;Alternatively, you could do:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; sourceTag=test index=test 
  | table user_id 
  | dedup user_id
  | JOIN user_id type=outer [search sourceTag=test index=test | rex "(?i)action: (?P&amp;lt;ACTION&amp;gt;[^ ]+)" | search ACTION="shop" | table user_id ACTION] 
  | fillnull value=NULL ACTION 
  | stats count(eval(ACTION="shop")) as ShopperCount, count(eval(ACTION!="shop")) as NonShopperCount
  | eval TotalUsers=ShopperCount+NonShopperCount
  | eval PercentageOfUsers=round(ShopperCount/TotalUsers*100,2)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 Mar 2015 16:06:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Question-regarding-join/m-p/193729#M55827</guid>
      <dc:creator>masonmorales</dc:creator>
      <dc:date>2015-03-24T16:06:48Z</dc:date>
    </item>
    <item>
      <title>Re: Question regarding join</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Question-regarding-join/m-p/193730#M55828</link>
      <description>&lt;P&gt;Ok the issue was my Action was nested and the eval didnt like that .... so &lt;BR /&gt;
stats count(eval(body.ACTION="shop")) would not work&lt;BR /&gt;
I renamed body.ACTION to ACTION&lt;BR /&gt;
and changed my query to &lt;BR /&gt;
count(eval(ACTION="shop")) &lt;BR /&gt;
and it now works great. Thanks for all your help!!&lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2015 16:26:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Question-regarding-join/m-p/193730#M55828</guid>
      <dc:creator>therockhead</dc:creator>
      <dc:date>2015-03-24T16:26:56Z</dc:date>
    </item>
  </channel>
</rss>

