<?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 do I edit my eval statement to insert a specified number in ColumnB based on specific values found in ColumnA? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-edit-my-eval-statement-to-insert-a-specified-number-in/m-p/224251#M66071</link>
    <description>&lt;P&gt;I think you need the case command here:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...
| eval rating=case(detail.overall="Very Satisfied", 100, detail.overall="Satisfied", 75 , detail.overall="Neither", 50, detail.overall="Dissatisfied", 25, detail.overall="Very Dissatisfied", 0 , 1=1, 0)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 11 Nov 2015 09:19:02 GMT</pubDate>
    <dc:creator>HeinzWaescher</dc:creator>
    <dc:date>2015-11-11T09:19:02Z</dc:date>
    <item>
      <title>How do I edit my eval statement to insert a specified number in ColumnB based on specific values found in ColumnA?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-edit-my-eval-statement-to-insert-a-specified-number-in/m-p/224250#M66070</link>
      <description>&lt;P&gt;Hi, I wonder whether someone may be able to help me please.&lt;/P&gt;

&lt;P&gt;I'm trying to run a search which looks at a value in column A (detail.overall), and if they contain specific values, then insert a specific value into the "Rating" column or zero.&lt;/P&gt;

&lt;P&gt;So if the detail.overall column is:&lt;/P&gt;

&lt;P&gt;Very Satisfied - Insert the value of 100 in the "Ratings" Column&lt;BR /&gt;
Satisfied - Insert the value of 75 in the "Ratings" Column&lt;BR /&gt;
Neither - Insert the value of 50 in the "Ratings" Column&lt;BR /&gt;
Dissatisfied - Insert the value of 25 in the "Ratings" Column&lt;BR /&gt;
Very Dissatisfied - Insert the value of 0 in the "Ratings" Column&lt;/P&gt;

&lt;P&gt;If none of the values are found, I'd like to insert a zero.&lt;/P&gt;

&lt;P&gt;This is the search I've put together so far:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main auditSource=frontend auditType=Survey detail.overall!="None" | replace frontend with "Overall Satisfaction" | replace 1 with "Very Satisfied", 2 with "Satisfied", 3 with "Neither", 4 with "Dissatisfied", 5 with "Very Dissatisfied" | chart count by detail.overall | addcoltotals|fillnull value="Total" count | eval Rating = if(match(detail.overall, "5"), "100", "0")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;There are two problems I have:&lt;/P&gt;

&lt;P&gt;[] Using the value "Very Satisfied", I'm unable to insert the value of 100 in the "Ratings" column&lt;BR /&gt;
[] I'm unsure how to create a nested if statement to take into all of the text values.&lt;/P&gt;

&lt;P&gt;I just wondered whether someone may be able to look at this please and offer some guidance on how I may be able to achieve this.&lt;/P&gt;

&lt;P&gt;Many thanks and kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2015 07:57:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-edit-my-eval-statement-to-insert-a-specified-number-in/m-p/224250#M66070</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2015-11-11T07:57:08Z</dc:date>
    </item>
    <item>
      <title>Re: How do I edit my eval statement to insert a specified number in ColumnB based on specific values found in ColumnA?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-edit-my-eval-statement-to-insert-a-specified-number-in/m-p/224251#M66071</link>
      <description>&lt;P&gt;I think you need the case command here:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...
| eval rating=case(detail.overall="Very Satisfied", 100, detail.overall="Satisfied", 75 , detail.overall="Neither", 50, detail.overall="Dissatisfied", 25, detail.overall="Very Dissatisfied", 0 , 1=1, 0)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Nov 2015 09:19:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-edit-my-eval-statement-to-insert-a-specified-number-in/m-p/224251#M66071</guid>
      <dc:creator>HeinzWaescher</dc:creator>
      <dc:date>2015-11-11T09:19:02Z</dc:date>
    </item>
    <item>
      <title>Re: How do I edit my eval statement to insert a specified number in ColumnB based on specific values found in ColumnA?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-edit-my-eval-statement-to-insert-a-specified-number-in/m-p/224252#M66072</link>
      <description>&lt;P&gt;Hi @HeinzWaescher, thank you very much for taking the time to reply to my post.&lt;/P&gt;

&lt;P&gt;I've tried your solution but unfortunately this doesn't work. I'm not sure whether this is because the solution is the opposite way around to my original post.&lt;/P&gt;

&lt;P&gt;I'd like if possible to insert the value into the Ratings column if:&lt;/P&gt;

&lt;P&gt;The detail.overall column value:&lt;/P&gt;

&lt;P&gt;Very Satisfied - Insert the value of 100 in the "Ratings" Column&lt;BR /&gt;
Satisfied - Insert the value of 75 in the "Ratings" Column&lt;BR /&gt;
Neither - Insert the value of 50 in the "Ratings" Column&lt;BR /&gt;
Dissatisfied - Insert the value of 25 in the "Ratings" Column&lt;BR /&gt;
Very Dissatisfied - Insert the value of 0 in the "Ratings" Column&lt;/P&gt;

&lt;P&gt;Many thanks and kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2015 09:30:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-edit-my-eval-statement-to-insert-a-specified-number-in/m-p/224252#M66072</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2015-11-11T09:30:22Z</dc:date>
    </item>
    <item>
      <title>Re: How do I edit my eval statement to insert a specified number in ColumnB based on specific values found in ColumnA?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-edit-my-eval-statement-to-insert-a-specified-number-in/m-p/224253#M66073</link>
      <description>&lt;P&gt;I mixed it up. Try my updated answer.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2015 09:36:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-edit-my-eval-statement-to-insert-a-specified-number-in/m-p/224253#M66073</guid>
      <dc:creator>HeinzWaescher</dc:creator>
      <dc:date>2015-11-11T09:36:47Z</dc:date>
    </item>
    <item>
      <title>Re: How do I edit my eval statement to insert a specified number in ColumnB based on specific values found in ColumnA?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-edit-my-eval-statement-to-insert-a-specified-number-in/m-p/224254#M66074</link>
      <description>&lt;P&gt;Hi, thank you very much for coming back to me with this.&lt;/P&gt;

&lt;P&gt;Unfortunately though, although the query does run, it is not inserting the values into the column and all rows remain zero.&lt;/P&gt;

&lt;P&gt;Many thanks and kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2015 09:41:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-edit-my-eval-statement-to-insert-a-specified-number-in/m-p/224254#M66074</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2015-11-11T09:41:19Z</dc:date>
    </item>
    <item>
      <title>Re: How do I edit my eval statement to insert a specified number in ColumnB based on specific values found in ColumnA?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-edit-my-eval-statement-to-insert-a-specified-number-in/m-p/224255#M66075</link>
      <description>&lt;P&gt;Hm, perhaps it does not like the dot in the fieldname?&lt;BR /&gt;
You could try out to pipe this before the eval command&lt;/P&gt;

&lt;P&gt;| rename detail.overall -&amp;gt; detail_overall &lt;BR /&gt;
| eval rating=case(detail_overall="Very Satisfied", 100, detail_overall="Satisfied", 75 , detail_overall="Neither", 50, detail_overall="Dissatisfied", 25, detail_overall="Very Dissatisfied", 0 , 1=1, 0)&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 07:51:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-edit-my-eval-statement-to-insert-a-specified-number-in/m-p/224255#M66075</guid>
      <dc:creator>HeinzWaescher</dc:creator>
      <dc:date>2020-09-29T07:51:23Z</dc:date>
    </item>
    <item>
      <title>Re: How do I edit my eval statement to insert a specified number in ColumnB based on specific values found in ColumnA?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-edit-my-eval-statement-to-insert-a-specified-number-in/m-p/224256#M66076</link>
      <description>&lt;P&gt;Hi, that's really very interesting about the '.' It now works perfectly!&lt;/P&gt;

&lt;P&gt;Many thanks and kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2015 09:52:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-edit-my-eval-statement-to-insert-a-specified-number-in/m-p/224256#M66076</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2015-11-11T09:52:25Z</dc:date>
    </item>
  </channel>
</rss>

