<?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 How to compare and list the difference between search result and lookup file? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-compare-and-list-the-difference-between-search-result-and/m-p/621024#M106980</link>
    <description>&lt;P&gt;hi team,&lt;/P&gt;
&lt;P&gt;1. I have a query with below 2 columns returned only&lt;/P&gt;
&lt;P&gt;PQ, ACT&lt;BR /&gt;pq1, act1&lt;BR /&gt;PQ1, act2&lt;BR /&gt;pQ1, act3&lt;BR /&gt;pq2, act4&lt;BR /&gt;QP2, act5&lt;BR /&gt;Pq2, act6&lt;BR /&gt;pq3, act7&lt;BR /&gt;Pq3, act8&lt;BR /&gt;pq_3, act9&lt;BR /&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Then I have a standard pq list csv file uploaded in splunk. In the csv file, there is a clumn called 'pq' with a standard pq values defined. please check below sample.&lt;/P&gt;
&lt;P&gt;PQ&lt;BR /&gt;pq1&lt;BR /&gt;pq2&lt;BR /&gt;pq3&lt;BR /&gt;pq4&lt;BR /&gt;pq5&lt;BR /&gt;pq6&lt;BR /&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. I want to compare the pq values in the splunk query result with the lookup csv file to find out&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; a) return the&amp;nbsp; PQ&amp;nbsp; and ACT that the PQ value is not exactly matched with the one defined in lookup file, include case sensitive issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;b) return the PQ and ACT that the PQ value is in the query result but not in the lookup table&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;c) return the PQ and ACT that PQ value is not in the query but in the lookup table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How to compose the query to meet the 3 requirements in step3?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BestRegards!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 17 Nov 2022 14:41:38 GMT</pubDate>
    <dc:creator>cheriemilk</dc:creator>
    <dc:date>2022-11-17T14:41:38Z</dc:date>
    <item>
      <title>How to compare and list the difference between search result and lookup file?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-compare-and-list-the-difference-between-search-result-and/m-p/621024#M106980</link>
      <description>&lt;P&gt;hi team,&lt;/P&gt;
&lt;P&gt;1. I have a query with below 2 columns returned only&lt;/P&gt;
&lt;P&gt;PQ, ACT&lt;BR /&gt;pq1, act1&lt;BR /&gt;PQ1, act2&lt;BR /&gt;pQ1, act3&lt;BR /&gt;pq2, act4&lt;BR /&gt;QP2, act5&lt;BR /&gt;Pq2, act6&lt;BR /&gt;pq3, act7&lt;BR /&gt;Pq3, act8&lt;BR /&gt;pq_3, act9&lt;BR /&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Then I have a standard pq list csv file uploaded in splunk. In the csv file, there is a clumn called 'pq' with a standard pq values defined. please check below sample.&lt;/P&gt;
&lt;P&gt;PQ&lt;BR /&gt;pq1&lt;BR /&gt;pq2&lt;BR /&gt;pq3&lt;BR /&gt;pq4&lt;BR /&gt;pq5&lt;BR /&gt;pq6&lt;BR /&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. I want to compare the pq values in the splunk query result with the lookup csv file to find out&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; a) return the&amp;nbsp; PQ&amp;nbsp; and ACT that the PQ value is not exactly matched with the one defined in lookup file, include case sensitive issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;b) return the PQ and ACT that the PQ value is in the query result but not in the lookup table&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;c) return the PQ and ACT that PQ value is not in the query but in the lookup table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How to compose the query to meet the 3 requirements in step3?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BestRegards!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 14:41:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-compare-and-list-the-difference-between-search-result-and/m-p/621024#M106980</guid>
      <dc:creator>cheriemilk</dc:creator>
      <dc:date>2022-11-17T14:41:38Z</dc:date>
    </item>
    <item>
      <title>Re: Help - How to compare and list the difference between search result and lookup file?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-compare-and-list-the-difference-between-search-result-and/m-p/621026#M106981</link>
      <description>&lt;LI-CODE lang="markup"&gt;&amp;lt;your search&amp;gt;
| eval from="query"
| append [| inputlookup pq.csv | eval from="csv"]
| stats values(ACT) as ACT values(from) as from by PQ
| where mvcount(from) &amp;gt; 1&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 16 Nov 2022 08:29:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-compare-and-list-the-difference-between-search-result-and/m-p/621026#M106981</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-11-16T08:29:37Z</dc:date>
    </item>
    <item>
      <title>Re: Help - How to compare and list the difference between search result and lookup file?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-compare-and-list-the-difference-between-search-result-and/m-p/621030#M106982</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/218024"&gt;@cheriemilk&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;please try something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;your_search&amp;gt;
| eval PQ=lower(PQ)
| stats count values(ACT) AS ACT BY PQ
| eval status="main"
| append [ | inputlookup your_lookup.csv | eval PQ=lower(PQ), status="lookup" | fields PQ count status ]
| stats sum(count) AS total values(ACT) AS ACT values(status) AS status dc(status) AS status_count BY PQ
| eval status=if(status-count=2,"both",status)
| table PQ ACT status&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 16 Nov 2022 08:35:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-compare-and-list-the-difference-between-search-result-and/m-p/621030#M106982</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-11-16T08:35:00Z</dc:date>
    </item>
    <item>
      <title>Re: Help - How to compare and list the difference between search result and lookup file?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-compare-and-list-the-difference-between-search-result-and/m-p/621035#M106983</link>
      <description>&lt;P&gt;Can you clarify a bit what you mean with point a about the non-exact matches? Can you (given this sample data) sketch what the expected output of the query would be?&lt;/P&gt;&lt;P&gt;E.g. having Pq3, pq3 and pq_3, do you want the query to just tell you that pq3 exists in the lookup but Pq3 and pq_3 don't? Or should the query try to also match those 'imperfect' cases and if so should the query highlight that it is a non-exact match?&lt;/P&gt;&lt;P&gt;What you could do to cover all that is this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;First: create a lookup definition "pq" that refers to the pq.csv lookup file and configure that lookup definition to be case sensitive (as it is by default I believe)&lt;BR /&gt;Then, run this query (not tested, so you may need to debug the SPL a bit in case I made some typo or so):&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;...your current query...
| eval cleanedPQ = replace(lower(PQ),"[^a-z0-9]","")
| eval from="query"
| append [ | inputlookup pq.csv | eval from="csv" | eval cleanedPQ = PQ]
| eventstats dc(from) as exact_match by PQ
| eventstats dc(from) as nonexact_match by cleanedPQ
| eval match = case(exact_match&amp;gt;1,"exact",non_exact_match&amp;gt;1,"non-exact",true(),"no match")
| stats values(from) as from values(match) as match values(ACT) as ACT values(cleanedPQ) as cleanedPQ by PQ&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 16 Nov 2022 10:32:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-compare-and-list-the-difference-between-search-result-and/m-p/621035#M106983</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2022-11-16T10:32:13Z</dc:date>
    </item>
    <item>
      <title>Re: Help - How to compare and list the difference between search result and lookup file?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-compare-and-list-the-difference-between-search-result-and/m-p/621178#M106998</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the help. is the stats&amp;nbsp; values() function case senstive? Does it treat 'PQ1' , 'pq2', 'Pq2' and 'pQ2' as a same value or treat them to 4 different values?&lt;/P&gt;&lt;PRE&gt;| stats values(ACT) as ACT values(from) as from by PQ&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 06:40:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-compare-and-list-the-difference-between-search-result-and/m-p/621178#M106998</guid>
      <dc:creator>cheriemilk</dc:creator>
      <dc:date>2022-11-17T06:40:29Z</dc:date>
    </item>
    <item>
      <title>Re: Help - How to compare and list the difference between search result and lookup file?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-compare-and-list-the-difference-between-search-result-and/m-p/621179#M106999</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the help.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 06:31:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-compare-and-list-the-difference-between-search-result-and/m-p/621179#M106999</guid>
      <dc:creator>cheriemilk</dc:creator>
      <dc:date>2022-11-17T06:31:41Z</dc:date>
    </item>
    <item>
      <title>Re: Help - How to compare and list the difference between search result and lookup file?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-compare-and-list-the-difference-between-search-result-and/m-p/621181#M107000</link>
      <description>&lt;P&gt;The by PQ will treat the values in these fields case-sensitively i.e. PQ1 is not the same as Pq1 or pQ1 or pq1&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 06:47:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-compare-and-list-the-difference-between-search-result-and/m-p/621181#M107000</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-11-17T06:47:57Z</dc:date>
    </item>
    <item>
      <title>Re: Help - How to compare and list the difference between search result and lookup file?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-compare-and-list-the-difference-between-search-result-and/m-p/621183#M107001</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/218024"&gt;@cheriemilk&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;if one answer solves your need, please accept one answer for the other people of Community or tell us how we can help you.&lt;/P&gt;&lt;P&gt;Ciao and happy splunking&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;P.S.: Karma Points are appreciated by all the Contributors;-)&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 06:52:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-compare-and-list-the-difference-between-search-result-and/m-p/621183#M107001</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-11-17T06:52:07Z</dc:date>
    </item>
  </channel>
</rss>

