<?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: Can we categorize the into fields based on the value of the field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Can-we-categorize-the-into-fields-based-on-the-value-of-the/m-p/371619#M109364</link>
    <description>&lt;P&gt;This one worked ,I was using this one but I was using wildcharater * which was throwing me an error&lt;/P&gt;

&lt;P&gt;Thanks a lot&lt;/P&gt;</description>
    <pubDate>Wed, 15 Nov 2017 17:38:58 GMT</pubDate>
    <dc:creator>vrmandadi</dc:creator>
    <dc:date>2017-11-15T17:38:58Z</dc:date>
    <item>
      <title>Can we categorize the into fields based on the value of the field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-we-categorize-the-into-fields-based-on-the-value-of-the/m-p/371610#M109355</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I have the below field with values&lt;/P&gt;

&lt;P&gt;Source&lt;/P&gt;

&lt;P&gt;abc_hd&lt;BR /&gt;
xyz_hd&lt;BR /&gt;
ppp&lt;BR /&gt;
sqr_sd&lt;BR /&gt;
aaa_sd&lt;/P&gt;

&lt;P&gt;I want to create a new field called version with values as SD and HD,all the values with the _HD are HD and the other is counted as SD LIKE BELOW&lt;/P&gt;

&lt;P&gt;Version&lt;BR /&gt;
SD-3&lt;BR /&gt;
hd-2&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:48:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-we-categorize-the-into-fields-based-on-the-value-of-the/m-p/371610#M109355</guid>
      <dc:creator>vrmandadi</dc:creator>
      <dc:date>2020-09-29T16:48:27Z</dc:date>
    </item>
    <item>
      <title>Re: Can we categorize the into fields based on the value of the field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-we-categorize-the-into-fields-based-on-the-value-of-the/m-p/371611#M109356</link>
      <description>&lt;P&gt;You can try like this (function coalesce is setting &lt;CODE&gt;sd&lt;/CODE&gt; as default value of no version if found on Source)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your search with field Source
| eval Version=coalesce(mvindex(split(Source,"_"),-1),"sd")
| stats count by Version
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Nov 2017 16:59:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-we-categorize-the-into-fields-based-on-the-value-of-the/m-p/371611#M109356</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-11-15T16:59:39Z</dc:date>
    </item>
    <item>
      <title>Re: Can we categorize the into fields based on the value of the field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-we-categorize-the-into-fields-based-on-the-value-of-the/m-p/371612#M109357</link>
      <description>&lt;P&gt;Hi vrmandadi&lt;BR /&gt;
try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your_search
| rex field=source "(?&amp;lt;HD&amp;gt;hd|HD)$"
| eval Version=if(HD=*,"HD","SD")
| stats count BY Version
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2017 16:59:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-we-categorize-the-into-fields-based-on-the-value-of-the/m-p/371612#M109357</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-11-15T16:59:53Z</dc:date>
    </item>
    <item>
      <title>Re: Can we categorize the into fields based on the value of the field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-we-categorize-the-into-fields-based-on-the-value-of-the/m-p/371613#M109358</link>
      <description>&lt;P&gt;For this, I'd use a &lt;CODE&gt;case&lt;/CODE&gt; statement and evaluate the field value with &lt;CODE&gt;like&lt;/CODE&gt; to find the matching values and then use &lt;CODE&gt;eventstats&lt;/CODE&gt; to count the matches before appending the type and count to create the desired &lt;CODE&gt;Version&lt;/CODE&gt; field:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[ base search ] | eval type=case(like(Source, "%_hd"), "HD", like(Source, "%_sd"), "SD") | eventstats count BY type | eval Version=type."-".count | fields - type count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Nov 2017 17:07:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-we-categorize-the-into-fields-based-on-the-value-of-the/m-p/371613#M109358</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2017-11-15T17:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: Can we categorize the into fields based on the value of the field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-we-categorize-the-into-fields-based-on-the-value-of-the/m-p/371614#M109359</link>
      <description>&lt;P&gt;Hi cudello,&lt;BR /&gt;
I am getting the below error&lt;/P&gt;

&lt;P&gt;Error in 'eval' command: The expression is malformed. An unexpected character is reached at '*,"HD","SD")'.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2017 17:14:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-we-categorize-the-into-fields-based-on-the-value-of-the/m-p/371614#M109359</guid>
      <dc:creator>vrmandadi</dc:creator>
      <dc:date>2017-11-15T17:14:15Z</dc:date>
    </item>
    <item>
      <title>Re: Can we categorize the into fields based on the value of the field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-we-categorize-the-into-fields-based-on-the-value-of-the/m-p/371615#M109360</link>
      <description>&lt;P&gt;Hi somesoni2 it only extracted HD &lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2017 17:14:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-we-categorize-the-into-fields-based-on-the-value-of-the/m-p/371615#M109360</guid>
      <dc:creator>vrmandadi</dc:creator>
      <dc:date>2017-11-15T17:14:46Z</dc:date>
    </item>
    <item>
      <title>Re: Can we categorize the into fields based on the value of the field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-we-categorize-the-into-fields-based-on-the-value-of-the/m-p/371616#M109361</link>
      <description>&lt;P&gt;hello elliotproebstel,&lt;/P&gt;

&lt;P&gt;the SD ones some have _SD and some dont ,I tried your query but this not show any results&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2017 17:18:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-we-categorize-the-into-fields-based-on-the-value-of-the/m-p/371616#M109361</guid>
      <dc:creator>vrmandadi</dc:creator>
      <dc:date>2017-11-15T17:18:56Z</dc:date>
    </item>
    <item>
      <title>Re: Can we categorize the into fields based on the value of the field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-we-categorize-the-into-fields-based-on-the-value-of-the/m-p/371617#M109362</link>
      <description>&lt;P&gt;Can you post some sample (if possible real value with sensitive data replaced with dummy char, try to keep the punctuations) where it failed to extract? It assumes that last segment after underscore is version in the values of field Source.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2017 17:20:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-we-categorize-the-into-fields-based-on-the-value-of-the/m-p/371617#M109362</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-11-15T17:20:25Z</dc:date>
    </item>
    <item>
      <title>Re: Can we categorize the into fields based on the value of the field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-we-categorize-the-into-fields-based-on-the-value-of-the/m-p/371618#M109363</link>
      <description>&lt;P&gt;Also give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your search with field Source
 | eval Version=if(match(Source,"_hd"),"HD","SD")
 | stats count by Version
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Nov 2017 17:25:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-we-categorize-the-into-fields-based-on-the-value-of-the/m-p/371618#M109363</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-11-15T17:25:14Z</dc:date>
    </item>
    <item>
      <title>Re: Can we categorize the into fields based on the value of the field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-we-categorize-the-into-fields-based-on-the-value-of-the/m-p/371619#M109364</link>
      <description>&lt;P&gt;This one worked ,I was using this one but I was using wildcharater * which was throwing me an error&lt;/P&gt;

&lt;P&gt;Thanks a lot&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2017 17:38:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-we-categorize-the-into-fields-based-on-the-value-of-the/m-p/371619#M109364</guid>
      <dc:creator>vrmandadi</dc:creator>
      <dc:date>2017-11-15T17:38:58Z</dc:date>
    </item>
    <item>
      <title>Re: Can we categorize the into fields based on the value of the field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-we-categorize-the-into-fields-based-on-the-value-of-the/m-p/371620#M109365</link>
      <description>&lt;P&gt;Ah, yes, I missed that nuance. Sorry! Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; [ base search ] | eval type=if(like(Source, "%_hd"), "HD", "SD") | eventstats count BY type | eval Version=type."-".count | fields - type count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That should assign &lt;CODE&gt;HD&lt;/CODE&gt; as the type for events containing &lt;CODE&gt;_hd&lt;/CODE&gt; and assign &lt;CODE&gt;SD&lt;/CODE&gt; as the type for all others.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2017 19:12:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-we-categorize-the-into-fields-based-on-the-value-of-the/m-p/371620#M109365</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2017-11-15T19:12:46Z</dc:date>
    </item>
    <item>
      <title>Re: Can we categorize the into fields based on the value of the field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-we-categorize-the-into-fields-based-on-the-value-of-the/m-p/371621#M109366</link>
      <description>&lt;P&gt;Thank you ,I tried this | eval Version=if(match(Source,"_hd"),"HD","SD")&lt;BR /&gt;
  | stats count by Version &lt;/P&gt;

&lt;P&gt;I was actually using wild character and it was throwing error&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2017 21:29:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-we-categorize-the-into-fields-based-on-the-value-of-the/m-p/371621#M109366</guid>
      <dc:creator>vrmandadi</dc:creator>
      <dc:date>2017-11-15T21:29:37Z</dc:date>
    </item>
    <item>
      <title>Re: Can we categorize the into fields based on the value of the field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-we-categorize-the-into-fields-based-on-the-value-of-the/m-p/371622#M109367</link>
      <description>&lt;P&gt;try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your_search
 | rex field=source "(?&amp;lt;HD&amp;gt;hd|HD)$"
 | eval Version=if(HD="*","HD","SD")
 | stats count BY Version
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2017 10:29:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-we-categorize-the-into-fields-based-on-the-value-of-the/m-p/371622#M109367</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-11-16T10:29:53Z</dc:date>
    </item>
  </channel>
</rss>

