<?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: eval case before inputlookup file search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/eval-case-before-inputlookup-file-search/m-p/372888#M109660</link>
    <description>&lt;P&gt;@surekhasplunk, is there any problem with using single csv file &lt;CODE&gt;myfile.csv&lt;/CODE&gt;? Just as country_abbreviation as a new column. This way you will not need to join two lookup files for same field.&lt;/P&gt;</description>
    <pubDate>Fri, 17 Nov 2017 10:54:13 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2017-11-17T10:54:13Z</dc:date>
    <item>
      <title>eval case before inputlookup file search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-case-before-inputlookup-file-search/m-p/372875#M109647</link>
      <description>&lt;P&gt;I have a dashboard table with fields like below. &lt;BR /&gt;
Area  field2 filed3&lt;BR /&gt;
UK     100    200&lt;BR /&gt;
US      300   400&lt;/P&gt;

&lt;P&gt;In the drill down i am using a query to find some fileds from the lookup file used here to show some fields. &lt;BR /&gt;
Now the problem is with the names under Area column&lt;/P&gt;

&lt;P&gt;While displaying in the dashboard i used eval to rename the values to short names as UK instead of United Kingdom. &lt;/P&gt;

&lt;P&gt;So in the lookup file United Kingdom and United States exists but UK and US doens not. &lt;/P&gt;

&lt;P&gt;So while using a drill down i am using $row.Area$  token and using search query but since row.filed value comes as UK its unable to search in lookup file. So how to make it work so that i can evaluate my query with some case values if UK then change it to United Kingdoma and then search in lookup file and get all desired fileds. &lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2017 13:57:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-case-before-inputlookup-file-search/m-p/372875#M109647</guid>
      <dc:creator>surekhasplunk</dc:creator>
      <dc:date>2017-11-16T13:57:23Z</dc:date>
    </item>
    <item>
      <title>Re: eval case before inputlookup file search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-case-before-inputlookup-file-search/m-p/372876#M109648</link>
      <description>&lt;P&gt;I'd recommend that you not use an eval to change the value of the field. Instead, use a &lt;CODE&gt;fieldformat&lt;/CODE&gt; command to change the display of the field but not the actual value. For example, I assume your current eval to replace &lt;CODE&gt;United States&lt;/CODE&gt; with &lt;CODE&gt;US&lt;/CODE&gt; and replace &lt;CODE&gt;United Kingdom&lt;/CODE&gt; with &lt;CODE&gt;UK&lt;/CODE&gt; looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[ base search ] | eval Area=case(match(Area, "United States"), "US", match(Area, "United Kingdom"), "UK")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you replace &lt;CODE&gt;eval&lt;/CODE&gt; with &lt;CODE&gt;fieldformat&lt;/CODE&gt;, Splunk will still display "US" in place of "United States", but the actual value of the field will remain unchanged. This will allow you to reference it in the drilldown token. So here's the revised query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[ base search ] | fieldformat Area=case(match(Area, "United States"), "US", match(Area, "United Kingdom"), "UK")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Check out some info on &lt;CODE&gt;fieldformat&lt;/CODE&gt; here:&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/7.0.0/SearchReference/Fieldformat"&gt;http://docs.splunk.com/Documentation/Splunk/7.0.0/SearchReference/Fieldformat&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2017 14:29:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-case-before-inputlookup-file-search/m-p/372876#M109648</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2017-11-16T14:29:08Z</dc:date>
    </item>
    <item>
      <title>Re: eval case before inputlookup file search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-case-before-inputlookup-file-search/m-p/372877#M109649</link>
      <description>&lt;P&gt;One solution would be to have both the short and long Area values in your .csv file, so it will find an answer either way if you do the lookup for both the original dashboard and the drilldown.  This would work for both the short and long Area names.  Also, this would be better than using a eval/case statement, as eval/case would essentially remove the general flexibility of a lookup as values are added/changed/deleted in the .csv file, since they would also have to be managed in the eval/case.  My assumption here is that there isn't some other mitigating factor that I'm not aware of that would preclude using this approach.&lt;/P&gt;

&lt;P&gt;lookup .csv file:&lt;/P&gt;

&lt;P&gt;Area1                    Area2&lt;BR /&gt;
United States       US&lt;BR /&gt;
United Kingdom  UK&lt;BR /&gt;
US                           United States&lt;BR /&gt;
UK                           United Kingdom&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2017 14:37:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-case-before-inputlookup-file-search/m-p/372877#M109649</guid>
      <dc:creator>jenaugle</dc:creator>
      <dc:date>2017-11-16T14:37:50Z</dc:date>
    </item>
    <item>
      <title>Re: eval case before inputlookup file search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-case-before-inputlookup-file-search/m-p/372878#M109650</link>
      <description>&lt;P&gt;Hi @elliotproebstel,&lt;/P&gt;

&lt;P&gt;I followed what you said and tried to change my drilldown query but looks like its not getting me any result. &lt;/P&gt;

&lt;P&gt;|inputlookup myfile.csv | search Area = "United States" | fieldformat Area=case(match(Area, "United States"), "US", match(Area, "United Kingdom"), "UK")   |fields employee_name "Employee ID"&lt;/P&gt;

&lt;P&gt;Here i feel since its  trying to search first for the vale "United States" and then trying to format it. so is that causing no rsults or whats the issue ? &lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2017 15:44:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-case-before-inputlookup-file-search/m-p/372878#M109650</guid>
      <dc:creator>surekhasplunk</dc:creator>
      <dc:date>2017-11-16T15:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: eval case before inputlookup file search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-case-before-inputlookup-file-search/m-p/372879#M109651</link>
      <description>&lt;P&gt;Just to clarify - the intent of my suggestion was that you use the &lt;CODE&gt;fieldformat&lt;/CODE&gt; command in your original query to preserve the value of the field &lt;CODE&gt;Area&lt;/CODE&gt; before it was passed to the drilldown. The query you posted above has no need for a &lt;CODE&gt;fieldformat&lt;/CODE&gt; at all, since you are ultimately displaying only the employee_name and "Employee ID" fields. Does this command return any results?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|inputlookup myfile.csv | search Area="United States" | fields employee_name "Employee ID"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If it does, then you should be able to apply the &lt;CODE&gt;fieldformat&lt;/CODE&gt; command string to your original search (in place of where you are using an &lt;CODE&gt;eval&lt;/CODE&gt;/&lt;CODE&gt;case&lt;/CODE&gt; statement. The drilldown will pass a token like &lt;CODE&gt;$row.Area$&lt;/CODE&gt; to the drilldown search, and you'll use &lt;CODE&gt;$row.Area$&lt;/CODE&gt; like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|inputlookup myfile.csv | search Area="$row.Area$" | fields employee_name "Employee ID"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Nov 2017 16:32:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-case-before-inputlookup-file-search/m-p/372879#M109651</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2017-11-16T16:32:49Z</dc:date>
    </item>
    <item>
      <title>Re: eval case before inputlookup file search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-case-before-inputlookup-file-search/m-p/372880#M109652</link>
      <description>&lt;P&gt;@surekhasplunk, I will agree with @jenaugle, you should update your lookup table to have both Full Country name as well as abbreviated name. You can find the same in &lt;CODE&gt;geo_attr_countries.csv&lt;/CODE&gt; lookup in the Splunk default Search App: &lt;CODE&gt;$SPLUNK_HOME$/etc/apps/search/lookups/geo_attr_countries.csv&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Try the following command check out the content of the lookup file:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| inputlookup geo_attr_countries.csv&lt;/CODE&gt;&lt;BR /&gt;
If you have your own lookup what you can do is perform a Splunk Search so that 2 letter abbreviated Country name is mapped with the Country name in your lookup and the remaining fields from your lookup file. Then you can either download result as CSV and replace your lookup with this or else if all rows look as expected you can pipe in &lt;CODE&gt;outputlook&lt;/CODE&gt; command to push the output table to your lookup file.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2017 16:34:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-case-before-inputlookup-file-search/m-p/372880#M109652</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-11-16T16:34:02Z</dc:date>
    </item>
    <item>
      <title>Re: eval case before inputlookup file search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-case-before-inputlookup-file-search/m-p/372881#M109653</link>
      <description>&lt;P&gt;I think i am not able to put my query clearly. &lt;BR /&gt;
Let me explain again. &lt;/P&gt;

&lt;P&gt;|inputlookup myfile.csv | search Area="United States" | fields employee_name "Employee ID"&lt;/P&gt;

&lt;P&gt;This retruns result since area has got full area name&lt;BR /&gt;
But in my dashboard the area name is just US&lt;BR /&gt;
So when i pass search Area="$row.Area$" it takes US instead of full name and query results nothing. &lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2017 16:43:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-case-before-inputlookup-file-search/m-p/372881#M109653</guid>
      <dc:creator>surekhasplunk</dc:creator>
      <dc:date>2017-11-16T16:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: eval case before inputlookup file search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-case-before-inputlookup-file-search/m-p/372882#M109654</link>
      <description>&lt;P&gt;Hi @niketnilay,&lt;BR /&gt;
Can i have a separate mapping.csv file just with the short name and full name in it then how should i write my query equivalent to and ammend the new mapping.csv file. &lt;/P&gt;

&lt;P&gt;|inputlookup myfile.csv | search Area="$row.Area$" | fields employee_name "Employee ID"&lt;/P&gt;

&lt;P&gt;Right now $row.Area$ is getting replaced by UK . Now how to  use mapping.csv file in the query so that i can tell if Area=UK search in mapping.csv and get the correspoding full name that is United Kindgom then assign that value to Area and the the requried Employee ID&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2017 17:30:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-case-before-inputlookup-file-search/m-p/372882#M109654</guid>
      <dc:creator>surekhasplunk</dc:creator>
      <dc:date>2017-11-16T17:30:10Z</dc:date>
    </item>
    <item>
      <title>Re: eval case before inputlookup file search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-case-before-inputlookup-file-search/m-p/372883#M109655</link>
      <description>&lt;P&gt;Ok, but in your original search that populated the dashboard, do you have a part of your search string that uses &lt;CODE&gt;eval&lt;/CODE&gt;/&lt;CODE&gt;case&lt;/CODE&gt; to replace "United States" with "US"? If so, that is the place where I am recommending you replace &lt;CODE&gt;eval&lt;/CODE&gt; with &lt;CODE&gt;fieldformat&lt;/CODE&gt;. &lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2017 17:37:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-case-before-inputlookup-file-search/m-p/372883#M109655</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2017-11-16T17:37:42Z</dc:date>
    </item>
    <item>
      <title>Re: eval case before inputlookup file search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-case-before-inputlookup-file-search/m-p/372884#M109656</link>
      <description>&lt;P&gt;Yes, you could certainly use two lookups, but it would be more efficient to add a single column to your original csv file. That way, you don't look up each field twice.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2017 17:40:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-case-before-inputlookup-file-search/m-p/372884#M109656</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2017-11-16T17:40:32Z</dc:date>
    </item>
    <item>
      <title>Re: eval case before inputlookup file search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-case-before-inputlookup-file-search/m-p/372885#M109657</link>
      <description>&lt;P&gt;Hi @elliotproebstel,&lt;/P&gt;

&lt;P&gt;Can you help me with the query using two lookups here&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2017 18:00:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-case-before-inputlookup-file-search/m-p/372885#M109657</guid>
      <dc:creator>surekhasplunk</dc:creator>
      <dc:date>2017-11-16T18:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: eval case before inputlookup file search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-case-before-inputlookup-file-search/m-p/372886#M109658</link>
      <description>&lt;P&gt;Sure. I'll assume your current dashboard search returns an event that contains the field &lt;CODE&gt;Area&lt;/CODE&gt;, which contains the value&lt;CODE&gt;US&lt;/CODE&gt;. So then you'll need a file called mapping.csv that has two columns:&lt;/P&gt;

&lt;PRE&gt;country_abbreviation, country_full
US,"United States"
...&lt;/PRE&gt;

&lt;P&gt;And then you have your existing file myfile.csv, and I'll assume you have multiple columns in that file, but one of them is something like &lt;CODE&gt;country&lt;/CODE&gt;, and it contains full country names like "United States". If all of that is true, then your search will look like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[ base search ] | lookup mapping.csv country_abbreviation AS Area OUTPUT country_full | lookup myfile.csv country AS country_full
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Nov 2017 18:11:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-case-before-inputlookup-file-search/m-p/372886#M109658</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2017-11-16T18:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: eval case before inputlookup file search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-case-before-inputlookup-file-search/m-p/372887#M109659</link>
      <description>&lt;P&gt;Hi am still struggling with this i am getting error error in lookup command. &lt;BR /&gt;
my query starts with inputlookup  and &lt;BR /&gt;
| inputlookup myfile.csv |search country= [|lookup mapping.csv |search country_full=”United States" |fields  country_abbreviation ]  | fields "Employee Forename"&lt;/P&gt;

&lt;P&gt;doesnot seem to be working. &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:49:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-case-before-inputlookup-file-search/m-p/372887#M109659</guid>
      <dc:creator>surekhasplunk</dc:creator>
      <dc:date>2020-09-29T16:49:41Z</dc:date>
    </item>
    <item>
      <title>Re: eval case before inputlookup file search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-case-before-inputlookup-file-search/m-p/372888#M109660</link>
      <description>&lt;P&gt;@surekhasplunk, is there any problem with using single csv file &lt;CODE&gt;myfile.csv&lt;/CODE&gt;? Just as country_abbreviation as a new column. This way you will not need to join two lookup files for same field.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2017 10:54:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-case-before-inputlookup-file-search/m-p/372888#M109660</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-11-17T10:54:13Z</dc:date>
    </item>
    <item>
      <title>Re: eval case before inputlookup file search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-case-before-inputlookup-file-search/m-p/372889#M109661</link>
      <description>&lt;P&gt;i just got it working with map command thanks&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2017 12:44:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-case-before-inputlookup-file-search/m-p/372889#M109661</guid>
      <dc:creator>surekhasplunk</dc:creator>
      <dc:date>2017-11-17T12:44:28Z</dc:date>
    </item>
  </channel>
</rss>

