<?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 you separate fields into different variables based on the beginning letter of field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-separate-fields-into-different-variables-based-on-the/m-p/383492#M111999</link>
    <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo EventCode=bar | eval Account_Type=case(Account_Name=="R*","AccountType1",Account_Name=="D*","AccountType2",Account_Name=="X*","AccountType3",1==1,"unknown" | stats count by Account_Type
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 28 Mar 2019 15:17:57 GMT</pubDate>
    <dc:creator>DMohn</dc:creator>
    <dc:date>2019-03-28T15:17:57Z</dc:date>
    <item>
      <title>How do you separate fields into different variables based on the beginning letter of field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-separate-fields-into-different-variables-based-on-the/m-p/383491#M111998</link>
      <description>&lt;P&gt;So I'm sure I'm missing something obvious, but I cannot for the life of me find something similar to what I'm looking for.&lt;/P&gt;

&lt;P&gt;I'm trying to take a search that returns all Accounts that have changed their password, and separate them into the 3 different types of accounts I have with a count. &lt;/P&gt;

&lt;P&gt;The different accounts start with different letters, which can be searched with &lt;CODE&gt;Account_Name=R*&lt;/CODE&gt; to get the R account type.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Index=foo EventCode=bar | act1=count(if Account_Name=R*), act2=count(if Account_Name=D*)...etc |table act1 act2 act3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I tried my best to find this, but I simply cannot figure out where to start with that conditional. &lt;/P&gt;

&lt;P&gt;Thank you in advance&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2019 15:03:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-separate-fields-into-different-variables-based-on-the/m-p/383491#M111998</guid>
      <dc:creator>ibdubs</dc:creator>
      <dc:date>2019-03-28T15:03:24Z</dc:date>
    </item>
    <item>
      <title>Re: How do you separate fields into different variables based on the beginning letter of field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-separate-fields-into-different-variables-based-on-the/m-p/383492#M111999</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo EventCode=bar | eval Account_Type=case(Account_Name=="R*","AccountType1",Account_Name=="D*","AccountType2",Account_Name=="X*","AccountType3",1==1,"unknown" | stats count by Account_Type
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Mar 2019 15:17:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-separate-fields-into-different-variables-based-on-the/m-p/383492#M111999</guid>
      <dc:creator>DMohn</dc:creator>
      <dc:date>2019-03-28T15:17:57Z</dc:date>
    </item>
    <item>
      <title>Re: How do you separate fields into different variables based on the beginning letter of field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-separate-fields-into-different-variables-based-on-the/m-p/383493#M112000</link>
      <description>&lt;P&gt;You would need to use string match functions of eval e.g. like or match for it.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=foo EventCode=bar | eval act1=count(like(Account_Name,"R%"),1,0) , act2=count(like(Account_Name,"D%"),1,0) ,acct3=count(like(Account_Name,"R%"),1,0)  | stats sum(act*) as act*
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Mar 2019 15:18:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-separate-fields-into-different-variables-based-on-the/m-p/383493#M112000</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2019-03-28T15:18:20Z</dc:date>
    </item>
    <item>
      <title>Re: How do you separate fields into different variables based on the beginning letter of field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-separate-fields-into-different-variables-based-on-the/m-p/383494#M112001</link>
      <description>&lt;P&gt;When I do this it labels them all as "unknown" but does contain the correct count next to it.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2019 15:29:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-separate-fields-into-different-variables-based-on-the/m-p/383494#M112001</guid>
      <dc:creator>ibdubs</dc:creator>
      <dc:date>2019-03-28T15:29:44Z</dc:date>
    </item>
    <item>
      <title>Re: How do you separate fields into different variables based on the beginning letter of field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-separate-fields-into-different-variables-based-on-the/m-p/383495#M112002</link>
      <description>&lt;P&gt;I get the below error with this version of the search&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;Error in 'eval' command: The 'count' function is unsupported or undefined&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Thu, 28 Mar 2019 15:30:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-separate-fields-into-different-variables-based-on-the/m-p/383495#M112002</guid>
      <dc:creator>ibdubs</dc:creator>
      <dc:date>2019-03-28T15:30:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do you separate fields into different variables based on the beginning letter of field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-separate-fields-into-different-variables-based-on-the/m-p/383496#M112003</link>
      <description>&lt;P&gt;Okay, then modify the query like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo EventCode=bar | eval Account_Type=case(like(Account_Name,"R%"),"AccountType1",like(Account_Name,"D%"),"AccountType2",like(Account_Name,"X%"),"AccountType3",1==1,"unknown") | stats count by Account_Type
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Mar 2019 15:32:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-separate-fields-into-different-variables-based-on-the/m-p/383496#M112003</guid>
      <dc:creator>DMohn</dc:creator>
      <dc:date>2019-03-28T15:32:34Z</dc:date>
    </item>
    <item>
      <title>Re: How do you separate fields into different variables based on the beginning letter of field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-separate-fields-into-different-variables-based-on-the/m-p/383497#M112004</link>
      <description>&lt;P&gt;This did require a "," after the first accounttype1 and a parenthesis at the end (for any future users) but this works perfectly thank you! Its been driving me nuts&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2019 15:46:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-separate-fields-into-different-variables-based-on-the/m-p/383497#M112004</guid>
      <dc:creator>ibdubs</dc:creator>
      <dc:date>2019-03-28T15:46:23Z</dc:date>
    </item>
    <item>
      <title>Re: How do you separate fields into different variables based on the beginning letter of field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-separate-fields-into-different-variables-based-on-the/m-p/383498#M112005</link>
      <description>&lt;P&gt;noted in a comment below&lt;BR /&gt;
&lt;CODE&gt;index=foo EventCode=bar | eval Account_Type=case(like(Account_Name,"R%"),"AccountType1",like(Account_Name,"D%"),"AccountType2",like(Account_Name,"X%"),"AccountType3",1==1,"unknown") | stats count by Account_Type&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2019 15:49:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-separate-fields-into-different-variables-based-on-the/m-p/383498#M112005</guid>
      <dc:creator>ibdubs</dc:creator>
      <dc:date>2019-03-28T15:49:55Z</dc:date>
    </item>
    <item>
      <title>Re: How do you separate fields into different variables based on the beginning letter of field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-separate-fields-into-different-variables-based-on-the/m-p/383499#M112006</link>
      <description>&lt;P&gt;Sorry, edited the typos for convenience. Glad it helped.&lt;/P&gt;

&lt;P&gt;If you could mark the answer as accepted it would help future users &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2019 15:51:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-separate-fields-into-different-variables-based-on-the/m-p/383499#M112006</guid>
      <dc:creator>DMohn</dc:creator>
      <dc:date>2019-03-28T15:51:49Z</dc:date>
    </item>
  </channel>
</rss>

