<?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 Find Unique Buildings Present in One Search but Not in Another in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-Find-Unique-Buildings-Present-in-One-Search-but-Not-in/m-p/694789#M236298</link>
    <description>&lt;P&gt;First off, the phrase "doesn't work" conveys little information in the best of cases and should be banished. &amp;nbsp;Describe your data and illustrate the output, then explain why the output is different from desired output unless it is painfully obvious. (See my Four Commandments below.)&lt;/P&gt;&lt;P&gt;Back to your search. &amp;nbsp;You already say that search does not meet your requirement. &amp;nbsp;Why insist on using append? &amp;nbsp;To get unique buildings in index events, you lookup any matching value, then exclude those matching events. &amp;nbsp;What is left are events with unmatched buildings. &amp;nbsp;Not only is this approach more semantic, but using lookup is also more efficient because that's a binary tree search.&lt;/P&gt;&lt;P&gt;About that&amp;nbsp;&lt;SPAN&gt;roomlookup_buildings.csv,&lt;/SPAN&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;SPAN&gt;have you defined a lookup to use this file? &amp;nbsp;In Splunk, a lookup definition can be independent of lookup file, meaning you need a definition. (The lookup definition doesn't have the use the same name as the file, but must use the file as source. &amp;nbsp;My convention is to name a lookup without .csv but that's up to you. &amp;nbsp;I will assume that your definition is called &lt;FONT face="courier new,courier"&gt;roomlookup_buildings.csv&lt;/FONT&gt;.)&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Are the column buildings containing one value per row? (I will assume yes. &amp;nbsp;There is no good reason not to.)&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;What are those escaped quotation marks? &amp;nbsp;Are they part of field value or do you simply use them to signal that between quotes are the values? (I will assume the values are between quotes.)&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;SPAN&gt;If you have already defined a lookup, let's also call it&amp;nbsp;roomlookup_buildings.csv; and let's assume that each row contains one value for building, i.e.,&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;buildings&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Aachen 1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Almanor 1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Almanor 2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Antara&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Further assume that your index search has these events:&lt;/P&gt;&lt;TABLE width="218px"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="178.46875px"&gt;building_from_search1&lt;/TD&gt;&lt;TD width="40px"&gt;request_unique_id&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="178.46875px"&gt;Aachen 1&lt;/TD&gt;&lt;TD width="40px"&gt;ID 1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="178.46875px"&gt;Almanor 1&lt;/TD&gt;&lt;TD width="40px"&gt;ID 2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="178.46875px"&gt;Almanor 2&lt;/TD&gt;&lt;TD width="40px"&gt;ID 2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="178.46875px"&gt;Amsterdam&lt;/TD&gt;&lt;TD width="40px"&gt;ID 3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Then, you run&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| lookup roomlookup_buildings.csv buildings as building_from_search1 output buildings as matching_building&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This should give you&lt;/P&gt;&lt;TABLE width="362px"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="178px"&gt;building_from_search1&lt;/TD&gt;&lt;TD width="144px"&gt;matching_building&lt;/TD&gt;&lt;TD width="40px"&gt;request_unique_id&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="178px"&gt;Aachen 1&lt;/TD&gt;&lt;TD width="144px"&gt;Aachen 1&lt;/TD&gt;&lt;TD width="40px"&gt;ID 1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="178px"&gt;Almanor 1&lt;/TD&gt;&lt;TD width="144px"&gt;Almanor 1&lt;/TD&gt;&lt;TD width="40px"&gt;ID 2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="178px"&gt;Almanor 2&lt;/TD&gt;&lt;TD width="144px"&gt;Almanor 2&lt;/TD&gt;&lt;TD width="40px"&gt;ID 2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="178px"&gt;Amsterdam&lt;/TD&gt;&lt;TD width="144px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="40px"&gt;ID 3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Apply the filter,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| lookup roomlookup_buildings.csv buildings as building_from_search1 output buildings as matching_building
| where isnull(matching_building)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This results in&lt;/P&gt;&lt;TABLE width="362px"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="178px"&gt;building_from_search1&lt;/TD&gt;&lt;TD width="144px"&gt;matching_building&lt;/TD&gt;&lt;TD width="40px"&gt;request_unique_id&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="178px"&gt;Amsterdam&lt;/TD&gt;&lt;TD width="144px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="40px"&gt;ID 3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Then, apply stats to the whole thing&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index= buildings_core "Buildings updated in database*"
| rex "REQUEST_UNIQUE_ID:(?&amp;lt;request_unique_id&amp;gt;[^ ]+)"
| rex "Buildings updated in database:\s(?&amp;lt;buildings&amp;gt;\{[^}]+\})"
| eval buildings = replace(buildings, "[{}]", "") | eval buildings = split(buildings, ",")
| mvexpand buildings
| eval building_from_search1 = mvindex(split(buildings, ":"), 1)
| lookup roomlookup_buildings.csv buildings as building_from_search1 output buildings as matching_building
| where isnull(matching_building)
| stats values(building_from_search1) as unmatching_buildings by request_unique_id&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That mock data gives&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;request_unique_id&lt;/TD&gt;&lt;TD&gt;unmatching_buildings&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ID 3&lt;/TD&gt;&lt;TD&gt;Amsterdam&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Is this what you expect from that mock data?&lt;/P&gt;&lt;P&gt;Here, I am illustrating four golden rules of asking an answerable question in data analytics, which I call Four Commandments:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Illustrate data input (in raw text, anonymize as needed), whether they are raw events or output from a search that volunteers here do not have to look at.&lt;/LI&gt;&lt;LI&gt;Illustrate the desired output from illustrated data.&lt;/LI&gt;&lt;LI&gt;Explain the logic between illustrated data and desired output&amp;nbsp;&lt;I&gt;without&lt;/I&gt;&amp;nbsp;SPL.&lt;/LI&gt;&lt;LI&gt;If you also illustrate attempted SPL, illustrate actual output and compare with desired output, explain why they look different&amp;nbsp;&lt;SPAN&gt;to you&lt;/SPAN&gt;&amp;nbsp;if that is not painfully obvious.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Here is an emulation for you to play with and compare with real data. &amp;nbsp;This emulation is used to generate the above mock data. &amp;nbsp;If your real data (including lookup) is different, you need to carefully describe them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults format=csv data="building_from_search1, request_unique_id
Aachen 1, ID 1
Almanor 1, ID 2
Almanor 2, ID 2
Amsterdam, ID 3"
``` the above emulates
index= buildings_core "Buildings updated in database*"
| rex "REQUEST_UNIQUE_ID:(?&amp;lt;request_unique_id&amp;gt;[^ ]+)"
| rex "Buildings updated in database:\s(?&amp;lt;buildings&amp;gt;\{[^}]+\})"
| eval buildings = replace(buildings, "[{}]", "") | eval buildings = split(buildings, ",")
| mvexpand buildings
| eval building_from_search1 = mvindex(split(buildings, ":"), 1)
```&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 31 Jul 2024 06:35:27 GMT</pubDate>
    <dc:creator>yuanliu</dc:creator>
    <dc:date>2024-07-31T06:35:27Z</dc:date>
    <item>
      <title>How to Find Unique Buildings Present in One Search but Not in Another</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Find-Unique-Buildings-Present-in-One-Search-but-Not-in/m-p/694724#M236278</link>
      <description>&lt;P&gt;Hi Splunk Community,&lt;/P&gt;
&lt;P&gt;I have a query that retrieves building data from two sources and I need assistance in identifying the unique buildings that are present in buildings_from_search1 but not in buildings_from_search2. Here's the query I'm currently using:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=buildings_core
|stats values(building_from_search1) as buildings_from_search1 by request_unique_id
| append [ | inputlookup roomlookup_buildings.csv
| stats values(building_from_search2) as buildings_from_search2 ]&lt;/LI-CODE&gt;
&lt;P&gt;Could someone please guide me on how to modify this query to get the unique buildings that are only present in buildings_from_search1 and not in buildings_from_search2?&lt;/P&gt;
&lt;P&gt;Thank you in advance for your help!&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2024 22:49:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Find-Unique-Buildings-Present-in-One-Search-but-Not-in/m-p/694724#M236278</guid>
      <dc:creator>Tajuddin</dc:creator>
      <dc:date>2024-07-30T22:49:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to Find Unique Buildings Present in One Search but Not in Another</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Find-Unique-Buildings-Present-in-One-Search-but-Not-in/m-p/694734#M236280</link>
      <description>&lt;P&gt;First, do not reach for inputlookup when lookup is readily applicable. &amp;nbsp;Assuming that you have distinct names in indexed events and the lookup, all you need to do is&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=buildings_core
| lookup roomlookup_buildings.csv building_from_search2 as building_from_search1 output building_from_search2
| where isnull(building_from_search2)
| stats values(building_from_search1) as unmatched_buildings_from_search1 by request_unique_id&lt;/LI-CODE&gt;&lt;P&gt;Here, I assume that you have already defined a lookup called&amp;nbsp;roomlookup_buildings.csv. (I usually name my lookups without that .csv.)&lt;/P&gt;&lt;P&gt;But then, why would you have different field names for the same thing? &amp;nbsp;If in both indexed events and lookup the field name is&amp;nbsp;&lt;FONT face="courier new,courier"&gt;building&lt;/FONT&gt;, you can do&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=buildings_core
| lookup roomlookup_buildings.csv building output building as matching_building
| where isnull(matching_building)
| stats values(building) as unique_buildings by request_unique_id&lt;/LI-CODE&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2024 21:26:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Find-Unique-Buildings-Present-in-One-Search-but-Not-in/m-p/694734#M236280</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-07-30T21:26:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to Find Unique Buildings Present in One Search but Not in Another</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Find-Unique-Buildings-Present-in-One-Search-but-Not-in/m-p/694780#M236296</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Sorry, but the previous approach hasn’t worked for me. Let me provide the full context with the entire query. I am trying to compare building names from two sources: an&lt;FONT color="#008000"&gt; indexed search&lt;/FONT&gt; and a &lt;FONT color="#008000"&gt;lookup file.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;For example, the &lt;FONT color="#FF6600"&gt;building_from_search1&lt;/FONT&gt; values from the indexed search are:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;FONT color="#0000FF"&gt;\"Aachen 1\"&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT color="#0000FF"&gt;\"Almanor 1\"&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT color="#0000FF"&gt;\"Almanor 2\"&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT color="#0000FF"&gt;\"Amsterdam\"&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;The lookup file, which has a column named &lt;FONT color="#FF6600"&gt;buildings&lt;/FONT&gt;, contains values like:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;FONT color="#0000FF"&gt;\"Aachen 1\"&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT color="#0000FF"&gt;\"Almanor 1\"&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT color="#0000FF"&gt;\"Almanor 2"&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT color="#0000FF"&gt;\"Antara"&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Currently, I am using the &lt;FONT color="#FF00FF"&gt;mvappend&lt;/FONT&gt; command to combine both sets and filter for values with a count of 1. However, this approach gives me unique values from both searches, not just the unique values from the indexed search.&lt;/P&gt;&lt;P&gt;The target is to print unique values from the indexed search only. In this example, "Amsterdam" should be included in the result, but I am currently getting both "Amsterdam" and "Antara."&lt;/P&gt;&lt;P&gt;Here is the query I am using:&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;index&lt;/FONT&gt;= buildings_core "Buildings updated in database*" | &lt;FONT color="#0000FF"&gt;rex&lt;/FONT&gt; "REQUEST_UNIQUE_ID:(?&amp;lt;request_unique_id&amp;gt;[^ ]+)" | &lt;FONT color="#0000FF"&gt;rex&lt;/FONT&gt; "Buildings updated in database:\s(?&amp;lt;buildings&amp;gt;\{[^}]+\})" | &lt;FONT color="#0000FF"&gt;eval&lt;/FONT&gt; buildings = replace(buildings, "[{}]", "") | &lt;FONT color="#0000FF"&gt;eval&lt;/FONT&gt; buildings = split(buildings, ",") | &lt;FONT color="#0000FF"&gt;mvexpand&lt;/FONT&gt; buildings | &lt;FONT color="#0000FF"&gt;eval&lt;/FONT&gt; building_from_search1 = mvindex(split(buildings, ":"), 1) | &lt;FONT color="#0000FF"&gt;stats&lt;/FONT&gt; values(building_from_search1) as buildings_from_search1 by request_unique_id | append [ | &lt;FONT color="#0000FF"&gt;inputlookup&lt;/FONT&gt; roomlookup_buildings.csv | stats values(buildings) as buildings_from_search2 ] | &lt;FONT color="#0000FF"&gt;eval&lt;/FONT&gt; all_buildings = mvappend(buildings_from_search1, buildings_from_search2) | &lt;FONT color="#0000FF"&gt;stats&lt;/FONT&gt; count by all_buildings | &lt;FONT color="#0000FF"&gt;where&lt;/FONT&gt; count = 1 | &lt;FONT color="#0000FF"&gt;stats&lt;/FONT&gt; values(all_buildings) as all_buildings | &lt;FONT color="#0000FF"&gt;eval&lt;/FONT&gt; source="buildings_lacking_timezone_data" | &lt;FONT color="#0000FF"&gt;table&lt;/FONT&gt; source, all_buildings&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2024 05:48:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Find-Unique-Buildings-Present-in-One-Search-but-Not-in/m-p/694780#M236296</guid>
      <dc:creator>Tajuddin</dc:creator>
      <dc:date>2024-07-31T05:48:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to Find Unique Buildings Present in One Search but Not in Another</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Find-Unique-Buildings-Present-in-One-Search-but-Not-in/m-p/694789#M236298</link>
      <description>&lt;P&gt;First off, the phrase "doesn't work" conveys little information in the best of cases and should be banished. &amp;nbsp;Describe your data and illustrate the output, then explain why the output is different from desired output unless it is painfully obvious. (See my Four Commandments below.)&lt;/P&gt;&lt;P&gt;Back to your search. &amp;nbsp;You already say that search does not meet your requirement. &amp;nbsp;Why insist on using append? &amp;nbsp;To get unique buildings in index events, you lookup any matching value, then exclude those matching events. &amp;nbsp;What is left are events with unmatched buildings. &amp;nbsp;Not only is this approach more semantic, but using lookup is also more efficient because that's a binary tree search.&lt;/P&gt;&lt;P&gt;About that&amp;nbsp;&lt;SPAN&gt;roomlookup_buildings.csv,&lt;/SPAN&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;SPAN&gt;have you defined a lookup to use this file? &amp;nbsp;In Splunk, a lookup definition can be independent of lookup file, meaning you need a definition. (The lookup definition doesn't have the use the same name as the file, but must use the file as source. &amp;nbsp;My convention is to name a lookup without .csv but that's up to you. &amp;nbsp;I will assume that your definition is called &lt;FONT face="courier new,courier"&gt;roomlookup_buildings.csv&lt;/FONT&gt;.)&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Are the column buildings containing one value per row? (I will assume yes. &amp;nbsp;There is no good reason not to.)&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;What are those escaped quotation marks? &amp;nbsp;Are they part of field value or do you simply use them to signal that between quotes are the values? (I will assume the values are between quotes.)&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;SPAN&gt;If you have already defined a lookup, let's also call it&amp;nbsp;roomlookup_buildings.csv; and let's assume that each row contains one value for building, i.e.,&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;buildings&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Aachen 1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Almanor 1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Almanor 2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Antara&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Further assume that your index search has these events:&lt;/P&gt;&lt;TABLE width="218px"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="178.46875px"&gt;building_from_search1&lt;/TD&gt;&lt;TD width="40px"&gt;request_unique_id&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="178.46875px"&gt;Aachen 1&lt;/TD&gt;&lt;TD width="40px"&gt;ID 1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="178.46875px"&gt;Almanor 1&lt;/TD&gt;&lt;TD width="40px"&gt;ID 2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="178.46875px"&gt;Almanor 2&lt;/TD&gt;&lt;TD width="40px"&gt;ID 2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="178.46875px"&gt;Amsterdam&lt;/TD&gt;&lt;TD width="40px"&gt;ID 3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Then, you run&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| lookup roomlookup_buildings.csv buildings as building_from_search1 output buildings as matching_building&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This should give you&lt;/P&gt;&lt;TABLE width="362px"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="178px"&gt;building_from_search1&lt;/TD&gt;&lt;TD width="144px"&gt;matching_building&lt;/TD&gt;&lt;TD width="40px"&gt;request_unique_id&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="178px"&gt;Aachen 1&lt;/TD&gt;&lt;TD width="144px"&gt;Aachen 1&lt;/TD&gt;&lt;TD width="40px"&gt;ID 1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="178px"&gt;Almanor 1&lt;/TD&gt;&lt;TD width="144px"&gt;Almanor 1&lt;/TD&gt;&lt;TD width="40px"&gt;ID 2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="178px"&gt;Almanor 2&lt;/TD&gt;&lt;TD width="144px"&gt;Almanor 2&lt;/TD&gt;&lt;TD width="40px"&gt;ID 2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="178px"&gt;Amsterdam&lt;/TD&gt;&lt;TD width="144px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="40px"&gt;ID 3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Apply the filter,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| lookup roomlookup_buildings.csv buildings as building_from_search1 output buildings as matching_building
| where isnull(matching_building)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This results in&lt;/P&gt;&lt;TABLE width="362px"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="178px"&gt;building_from_search1&lt;/TD&gt;&lt;TD width="144px"&gt;matching_building&lt;/TD&gt;&lt;TD width="40px"&gt;request_unique_id&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="178px"&gt;Amsterdam&lt;/TD&gt;&lt;TD width="144px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="40px"&gt;ID 3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Then, apply stats to the whole thing&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index= buildings_core "Buildings updated in database*"
| rex "REQUEST_UNIQUE_ID:(?&amp;lt;request_unique_id&amp;gt;[^ ]+)"
| rex "Buildings updated in database:\s(?&amp;lt;buildings&amp;gt;\{[^}]+\})"
| eval buildings = replace(buildings, "[{}]", "") | eval buildings = split(buildings, ",")
| mvexpand buildings
| eval building_from_search1 = mvindex(split(buildings, ":"), 1)
| lookup roomlookup_buildings.csv buildings as building_from_search1 output buildings as matching_building
| where isnull(matching_building)
| stats values(building_from_search1) as unmatching_buildings by request_unique_id&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That mock data gives&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;request_unique_id&lt;/TD&gt;&lt;TD&gt;unmatching_buildings&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ID 3&lt;/TD&gt;&lt;TD&gt;Amsterdam&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Is this what you expect from that mock data?&lt;/P&gt;&lt;P&gt;Here, I am illustrating four golden rules of asking an answerable question in data analytics, which I call Four Commandments:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Illustrate data input (in raw text, anonymize as needed), whether they are raw events or output from a search that volunteers here do not have to look at.&lt;/LI&gt;&lt;LI&gt;Illustrate the desired output from illustrated data.&lt;/LI&gt;&lt;LI&gt;Explain the logic between illustrated data and desired output&amp;nbsp;&lt;I&gt;without&lt;/I&gt;&amp;nbsp;SPL.&lt;/LI&gt;&lt;LI&gt;If you also illustrate attempted SPL, illustrate actual output and compare with desired output, explain why they look different&amp;nbsp;&lt;SPAN&gt;to you&lt;/SPAN&gt;&amp;nbsp;if that is not painfully obvious.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Here is an emulation for you to play with and compare with real data. &amp;nbsp;This emulation is used to generate the above mock data. &amp;nbsp;If your real data (including lookup) is different, you need to carefully describe them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults format=csv data="building_from_search1, request_unique_id
Aachen 1, ID 1
Almanor 1, ID 2
Almanor 2, ID 2
Amsterdam, ID 3"
``` the above emulates
index= buildings_core "Buildings updated in database*"
| rex "REQUEST_UNIQUE_ID:(?&amp;lt;request_unique_id&amp;gt;[^ ]+)"
| rex "Buildings updated in database:\s(?&amp;lt;buildings&amp;gt;\{[^}]+\})"
| eval buildings = replace(buildings, "[{}]", "") | eval buildings = split(buildings, ",")
| mvexpand buildings
| eval building_from_search1 = mvindex(split(buildings, ":"), 1)
```&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2024 06:35:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Find-Unique-Buildings-Present-in-One-Search-but-Not-in/m-p/694789#M236298</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-07-31T06:35:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to Find Unique Buildings Present in One Search but Not in Another</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Find-Unique-Buildings-Present-in-One-Search-but-Not-in/m-p/694822#M236305</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Thank a lot you for your help on this matter. I apologize for the confusion earlier; it turns out that the &lt;FONT color="#FF0000"&gt;building_from_index_search&lt;/FONT&gt; field did indeed contain multiple values per row, which was causing the matching issues. Adding the &lt;FONT color="#008000"&gt;| mvexpand building_from_index_search&lt;/FONT&gt; line helped by creating separate rows, which resolved the problem and allowed me to obtain the expected output.&lt;/P&gt;&lt;P&gt;Now, I’d like to address a similar requirement. While the current approach effectively identifies the unique values in &lt;FONT color="#FF6600"&gt;building_from_index_search&lt;/FONT&gt; that are not present in &lt;FONT color="#FF0000"&gt;roomlookup_buildings.csv buildings&lt;/FONT&gt;, I also need to find unique values specifically in the &lt;FONT color="#FF0000"&gt;roomlookup_buildings.csv buildings&lt;/FONT&gt; that do not appear in the &lt;FONT color="#FF0000"&gt;building_from_index_search&lt;/FONT&gt; field.&lt;/P&gt;&lt;P&gt;Could you help me with a query to achieve this?&amp;nbsp;Thank you in advance for your assistance!&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2024 13:10:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Find-Unique-Buildings-Present-in-One-Search-but-Not-in/m-p/694822#M236305</guid>
      <dc:creator>Tajuddin</dc:creator>
      <dc:date>2024-07-31T13:10:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to Find Unique Buildings Present in One Search but Not in Another</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Find-Unique-Buildings-Present-in-One-Search-but-Not-in/m-p/694846#M236312</link>
      <description>&lt;P&gt;For that, you use inputlookup. &amp;nbsp;It's simply the reverse logic. &amp;nbsp;I will use the same assumptions about your index search, with the same assumed field names.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup roomlookup_buildings.csv where NOT
    [search index= buildings_core "Buildings updated in database*"
    | rex "REQUEST_UNIQUE_ID:(?&amp;lt;request_unique_id&amp;gt;[^ ]+)"
    | rex "Buildings updated in database:\s(?&amp;lt;buildings&amp;gt;\{[^}]+\})"
    | eval buildings = replace(buildings, "[{}]", "") | eval buildings = split(buildings, ",")
    | mvexpand buildings
    | eval building_from_search1 = mvindex(split(buildings, ":"), 1)
    | fields building_from_search1
    | rename building_from_search1 as buildings]
| rename buildings as buildings_only_in_lookup&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using the same emulation as shown above, the mock data would give&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;buildings_only_in_lookup&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Antara&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Also a point that name buildiing_from_search1 (or &lt;SPAN&gt;building_from_index_search&lt;/SPAN&gt;&amp;nbsp;as in your latest comment). &amp;nbsp;Its value comes from an original field named "buildings" which is the same as in the lookup. &amp;nbsp;It is much easier to keep using that name on the left-hand side of the assignments because there don't appear to have use of the original value down the stream.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2024 16:12:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Find-Unique-Buildings-Present-in-One-Search-but-Not-in/m-p/694846#M236312</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-07-31T16:12:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to Find Unique Buildings Present in One Search but Not in Another</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Find-Unique-Buildings-Present-in-One-Search-but-Not-in/m-p/694903#M236325</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;It worked perfectly! Thank you so much for your help; you’ve saved me a great deal of time. I had been struggling for several days to implement this logic to create an alert, and now that I have an efficient approach, I’m happy to accept this as the solution.&lt;/P&gt;&lt;P&gt;Thanks again for your support!&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2024 19:40:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Find-Unique-Buildings-Present-in-One-Search-but-Not-in/m-p/694903#M236325</guid>
      <dc:creator>Tajuddin</dc:creator>
      <dc:date>2024-07-31T19:40:17Z</dc:date>
    </item>
  </channel>
</rss>

