<?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: find max length where field name is firstName_1,firstName_2... in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/find-max-length-where-field-name-is-firstName-1-firstName-2/m-p/410242#M118351</link>
    <description>&lt;P&gt;Thanks Kamlesh. It works&lt;/P&gt;</description>
    <pubDate>Wed, 22 Aug 2018 13:13:58 GMT</pubDate>
    <dc:creator>dummy1281</dc:creator>
    <dc:date>2018-08-22T13:13:58Z</dc:date>
    <item>
      <title>find max length where field name is firstName_1,firstName_2...</title>
      <link>https://community.splunk.com/t5/Splunk-Search/find-max-length-where-field-name-is-firstName-1-firstName-2/m-p/410236#M118345</link>
      <description>&lt;P&gt;My splunk entry is firstName_1="Tom" firstName_2="Jerry" firstName_3="Tom1" firstName_4="Jerry1"&lt;/P&gt;

&lt;P&gt;I would like to find max length of firstName. Answer for above entry should be 6 as firstName_4 length is Jerry1 (6)&lt;/P&gt;

&lt;P&gt;Tried | table firstName_* but getting all the values in table and to find max length, I need to find the length manually.&lt;/P&gt;

&lt;P&gt;Tried | eval len (firstName_*) but getting error.&lt;/P&gt;

&lt;P&gt;Can you please help me with this. Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:55:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/find-max-length-where-field-name-is-firstName-1-firstName-2/m-p/410236#M118345</guid>
      <dc:creator>dummy1281</dc:creator>
      <dc:date>2020-09-29T20:55:44Z</dc:date>
    </item>
    <item>
      <title>Re: find max length where field name is firstName_1,firstName_2...</title>
      <link>https://community.splunk.com/t5/Splunk-Search/find-max-length-where-field-name-is-firstName-1-firstName-2/m-p/410237#M118346</link>
      <description>&lt;P&gt;Use &lt;CODE&gt;foreach&lt;/CODE&gt; to process each firstName_* field.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval maxLen=0 | foreach firstName_* [eval maxLen=if(len(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;) &amp;gt; maxLen, len(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;), maxLen)] | ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Aug 2018 14:32:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/find-max-length-where-field-name-is-firstName-1-firstName-2/m-p/410237#M118346</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2018-08-16T14:32:19Z</dc:date>
    </item>
    <item>
      <title>Re: find max length where field name is firstName_1,firstName_2...</title>
      <link>https://community.splunk.com/t5/Splunk-Search/find-max-length-where-field-name-is-firstName-1-firstName-2/m-p/410238#M118347</link>
      <description>&lt;P&gt;I hope this will work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  ...| eval Max=0
 | foreach firstName_*
     [eval Max=case(Max&amp;gt;=len('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'),Max,true(),len('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'))]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Converted to comment since rich answer is more correct&lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2018 14:33:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/find-max-length-where-field-name-is-firstName-1-firstName-2/m-p/410238#M118347</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-08-16T14:33:30Z</dc:date>
    </item>
    <item>
      <title>Re: find max length where field name is firstName_1,firstName_2...</title>
      <link>https://community.splunk.com/t5/Splunk-Search/find-max-length-where-field-name-is-firstName-1-firstName-2/m-p/410239#M118348</link>
      <description>&lt;P&gt;I wouldn't say it's more correct.  Just different.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2018 15:54:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/find-max-length-where-field-name-is-firstName-1-firstName-2/m-p/410239#M118348</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2018-08-16T15:54:37Z</dc:date>
    </item>
    <item>
      <title>Re: find max length where field name is firstName_1,firstName_2...</title>
      <link>https://community.splunk.com/t5/Splunk-Search/find-max-length-where-field-name-is-firstName-1-firstName-2/m-p/410240#M118349</link>
      <description>&lt;P&gt;Thank you for your reply. When I try &lt;/P&gt;

&lt;P&gt;index=x | eval maxLen=0 | foreach firstName_* [eval maxLen=if(len(&amp;lt;&amp;gt;) &amp;gt; maxLen, len(&amp;lt;&amp;gt;), maxLen)]&lt;/P&gt;

&lt;P&gt;I am getting result as same for index=x&lt;/P&gt;

&lt;P&gt;but not the max length for firstName_*&lt;/P&gt;

&lt;P&gt;I'm really not sure what I'm missing. Can you please help.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Aug 2018 13:03:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/find-max-length-where-field-name-is-firstName-1-firstName-2/m-p/410240#M118349</guid>
      <dc:creator>dummy1281</dc:creator>
      <dc:date>2018-08-20T13:03:41Z</dc:date>
    </item>
    <item>
      <title>Re: find max length where field name is firstName_1,firstName_2...</title>
      <link>https://community.splunk.com/t5/Splunk-Search/find-max-length-where-field-name-is-firstName-1-firstName-2/m-p/410241#M118350</link>
      <description>&lt;P&gt;@dummy1281&lt;/P&gt;

&lt;P&gt;It should work.&lt;/P&gt;

&lt;P&gt;Can you please try this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=x 
| eval maxLen=0  
| foreach firstName_* 
    [ eval maxLen=case(maxLen&amp;gt;=len('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'),maxLen,true(),len('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'))] 
| table firstName* maxLen
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Sample search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval maxLen=0, firstName_1="Tom",firstName_2="Jerry",firstName_3="Tom1",firstName_4="Jerry1llll" 
| foreach firstName_* 
    [ eval maxLen=case(maxLen&amp;gt;=len('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'),maxLen,true(),len('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'))] 
| table firstName* maxLen
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 20 Aug 2018 13:34:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/find-max-length-where-field-name-is-firstName-1-firstName-2/m-p/410241#M118350</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2018-08-20T13:34:29Z</dc:date>
    </item>
    <item>
      <title>Re: find max length where field name is firstName_1,firstName_2...</title>
      <link>https://community.splunk.com/t5/Splunk-Search/find-max-length-where-field-name-is-firstName-1-firstName-2/m-p/410242#M118351</link>
      <description>&lt;P&gt;Thanks Kamlesh. It works&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 13:13:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/find-max-length-where-field-name-is-firstName-1-firstName-2/m-p/410242#M118351</guid>
      <dc:creator>dummy1281</dc:creator>
      <dc:date>2018-08-22T13:13:58Z</dc:date>
    </item>
  </channel>
</rss>

