<?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 have only common values for 2 fields in the same search? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-have-only-common-values-for-2-fields-in-the-same-search/m-p/434852#M191149</link>
    <description>&lt;P&gt;hi @tjosm &lt;/P&gt;

&lt;P&gt;Please let us know if your issue has been resolved and accept the answer if it significantly helped your resolution. Do not forget to add additional resolution details for the benefit of other form members.&lt;/P&gt;</description>
    <pubDate>Mon, 19 Aug 2019 15:00:30 GMT</pubDate>
    <dc:creator>Sukisen1981</dc:creator>
    <dc:date>2019-08-19T15:00:30Z</dc:date>
    <item>
      <title>How to have only common values for 2 fields in the same search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-have-only-common-values-for-2-fields-in-the-same-search/m-p/434850#M191147</link>
      <description>&lt;P&gt;I have a table like this:&lt;/P&gt;

&lt;P&gt;Shops               Location          Total&lt;BR /&gt;
1. CK                 SF                      1000&lt;BR /&gt;
2. CK                 LA                       877&lt;BR /&gt;
3. CK                 NY                       543&lt;BR /&gt;
4. CK                 BOS                     436&lt;BR /&gt;
5. OG                NY                      2112&lt;BR /&gt;
6. OG                DET                      100&lt;BR /&gt;
7. OG                ATL                      876&lt;BR /&gt;
8. OG                LA                         421&lt;/P&gt;

&lt;P&gt;I want a table/report like this:&lt;BR /&gt;
Shops               Location          Total&lt;BR /&gt;
1. CK                 LA                       877&lt;BR /&gt;
2. CK                 NY                       543&lt;BR /&gt;
3. OG                NY                      2112&lt;BR /&gt;
4. OG                LA                         421&lt;/P&gt;

&lt;P&gt;Code I have:&lt;BR /&gt;
    |tstats count where index=us-shops Shops IN (CK OG) Location=* by Shops,Location |sort - count| streamstats count as rank by Shops&lt;BR /&gt;
    | where rank &amp;lt; 9|stats sum(count)  by Shops,Location | rename sum(count) as Total&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2019 16:02:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-have-only-common-values-for-2-fields-in-the-same-search/m-p/434850#M191147</guid>
      <dc:creator>tjosm</dc:creator>
      <dc:date>2019-08-07T16:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to have only common values for 2 fields in the same search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-have-only-common-values-for-2-fields-in-the-same-search/m-p/434851#M191148</link>
      <description>&lt;P&gt;hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/198568"&gt;@tjosm&lt;/a&gt; &lt;BR /&gt;
Your query is a bit confusing,given you requirements.&lt;BR /&gt;
You need to have Total as a by clause in both stats and stream stats. You are loosing the field 'Total' and instead having sum of count as  Total which will probably give you output as 1 /(just the unique count), be that as it may I kinda took your initial data in a csv and added this code.&lt;BR /&gt;
    | stats count by Shops,Location,Total&lt;BR /&gt;
    |  sort - count| streamstats count as rank by Shops | where rank &amp;lt; 9|stats sum(count) by Shops,Location,Total | rename sum(count) as newtotal&lt;BR /&gt;
    | eventstats count as loc_count by Location &lt;BR /&gt;
    |  where loc_count&amp;gt;1&lt;BR /&gt;
    |  fields - newtotal, - loc_count&lt;/P&gt;

&lt;P&gt;tstats has become stats since i took the first data in a csv&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:44:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-have-only-common-values-for-2-fields-in-the-same-search/m-p/434851#M191148</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2020-09-30T01:44:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to have only common values for 2 fields in the same search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-have-only-common-values-for-2-fields-in-the-same-search/m-p/434852#M191149</link>
      <description>&lt;P&gt;hi @tjosm &lt;/P&gt;

&lt;P&gt;Please let us know if your issue has been resolved and accept the answer if it significantly helped your resolution. Do not forget to add additional resolution details for the benefit of other form members.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 15:00:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-have-only-common-values-for-2-fields-in-the-same-search/m-p/434852#M191149</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2019-08-19T15:00:30Z</dc:date>
    </item>
  </channel>
</rss>

