<?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: Not able to use Fields, Rename, Table command after Fieldformat command in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Not-able-to-use-Fields-Rename-Table-command-after-Fieldformat/m-p/275484#M83099</link>
    <description>&lt;P&gt;if i sort before and then use eval command, then in that case definetly it will show in sorted format. But as i have mentioned in the question as well, if i click on the field name then the sorting happens as a string because it contains Letters and special characters. Whereas if i use fieldformat, then it works exactly the way i want.&lt;/P&gt;

&lt;P&gt;The problem with fieldformat is, it works only when it is the last command in the search query. Incase if try to use fields command or even table command, the value formatted with fieldformat command becomes empty and hence the issue.&lt;/P&gt;</description>
    <pubDate>Fri, 16 Sep 2016 05:07:50 GMT</pubDate>
    <dc:creator>ashish9433</dc:creator>
    <dc:date>2016-09-16T05:07:50Z</dc:date>
    <item>
      <title>Not able to use Fields, Rename, Table command after Fieldformat command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Not-able-to-use-Fields-Rename-Table-command-after-Fieldformat/m-p/275476#M83091</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am trying to convert some values with combination of Alphabets, Special Characters and numbers but still want to retain the property to be number so as to be able to sort on numeric values. &lt;/P&gt;

&lt;P&gt;The below is an example -&amp;gt; &lt;STRONG&gt;3.4M (0.00/0.00%)&lt;/STRONG&gt; &lt;/P&gt;

&lt;P&gt;I am able to do this using &lt;STRONG&gt;fieldformat&lt;/STRONG&gt; command, if i use eval command then the numeric property of the field is not retained.&lt;/P&gt;

&lt;P&gt;Now the problem is commands like &lt;STRONG&gt;fields&lt;/STRONG&gt;, &lt;STRONG&gt;rename&lt;/STRONG&gt;, &lt;STRONG&gt;table&lt;/STRONG&gt; doesn't work. If any of these commands are used after fieldformat, then the field which was formatted using fieldformat becomes blank.&lt;/P&gt;

&lt;P&gt;Can any one guide me, how to overcome this issue.&lt;/P&gt;

&lt;P&gt;Note - It is not possible to use fields, rename, table commands before fieldformat in my search query. so need a work around to overcome this issue.&lt;/P&gt;

&lt;P&gt;Update - Search Query&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index = abc source="2016-09-12" | rename "Name" as Group  | lookup parents Node as Group | eval parentsSplit=split(Parents,"|") | table "Group", parentsSplit, "Critical Count" | search parentsSplit="*_OS*" | rename "Critical Count" as new | join type=outer Group [search index = abc source="2016-09-05" | rename "Name" as Group  | lookup parents Node as Group | eval parentsSplit=split(Parents,"|") | table "Group", parentsSplit, "Critical Count" | search parentsSplit="*_OS*" | rename "Critical Count" as old] | fillnull VALUE=0 | eval delta=new-old  | eval delta_perc=if(old==0,round((delta/1)*100,2),round((delta/old)*100,2)) | eval delta_perc = if(abs(delta_perc)&amp;gt;1000000,round(delta_perc/1000000,1)."M",if(abs(delta_perc)&amp;gt;1000,round(delta_perc/1000,1)."K",delta_perc)) | fieldformat new=if((abs(new)&amp;gt;1000000),round(new/1000000,1)."M",if((abs(new)&amp;gt;1000),round(new/1000,1)."K",round(new,2)))." (".if ((abs(delta)&amp;gt;1000000),if(round(delta/1000000,0)&amp;gt;0,"+".round(delta/1000000,1)."M",round(delta/1000000,1)."M"),if((abs(delta)&amp;gt;1000),if(round(delta/1000,0)&amp;gt;0,"+".round(delta/1000,1)."K",round(delta/1000,1)."K"),if(round(delta,2)&amp;gt;0,"+".round(delta,2),round(delta,2))))."/".delta_perc."%)" | 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The above query runs well and gives me the output i want, but once i add the below i get empty result&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;table Group, new | rename new AS "Val1"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So using table, rename command is not working after fieldformat command.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Sep 2016 11:16:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Not-able-to-use-Fields-Rename-Table-command-after-Fieldformat/m-p/275476#M83091</guid>
      <dc:creator>ashish9433</dc:creator>
      <dc:date>2016-09-13T11:16:34Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to use Fields, Rename, Table command after Fieldformat command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Not-able-to-use-Fields-Rename-Table-command-after-Fieldformat/m-p/275477#M83092</link>
      <description>&lt;P&gt;Please share your query.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Sep 2016 11:44:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Not-able-to-use-Fields-Rename-Table-command-after-Fieldformat/m-p/275477#M83092</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-09-13T11:44:09Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to use Fields, Rename, Table command after Fieldformat command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Not-able-to-use-Fields-Rename-Table-command-after-Fieldformat/m-p/275478#M83093</link>
      <description>&lt;P&gt;@sundareshr updated the search query.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Sep 2016 11:57:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Not-able-to-use-Fields-Rename-Table-command-after-Fieldformat/m-p/275478#M83093</guid>
      <dc:creator>ashish9433</dc:creator>
      <dc:date>2016-09-13T11:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to use Fields, Rename, Table command after Fieldformat command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Not-able-to-use-Fields-Rename-Table-command-after-Fieldformat/m-p/275479#M83094</link>
      <description>&lt;P&gt;My guess is the issue is with the &lt;CODE&gt;join&lt;/CODE&gt;. Try this updated search without the join. Also, I don't see a &lt;CODE&gt;result&lt;/CODE&gt; field anywhere in your search. is that coming from the lookup table? &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index = abc (source="2016-09-12" OR source="2016-09-05")
| rename "Name" as Group  
| lookup parents Node as Group 
| eval parentsSplit=split(Parents,"|") 
| table "Group", parentsSplit, "Critical Count" 
| search parentsSplit="*_OS*" 
| eval "Critical Count"=if(source="2016-09-05", "old", "new")
| fillnull VALUE=0 
| eval delta=new-old  
| eval delta_perc=if(old==0,round((delta/1)*100,2),round((delta/old)*100,2)) 
| eval delta_perc = if(abs(delta_perc)&amp;gt;1000000,round(delta_perc/1000000,1)."M",if(abs(delta_perc)&amp;gt;1000,round(delta_perc/1000,1)."K",delta_perc)) 
| fieldformat new=if((abs(new)&amp;gt;1000000),round(new/1000000,1)."M",if((abs(new)&amp;gt;1000),round(new/1000,1)."K",round(new,2)))." (".if ((abs(delta)&amp;gt;1000000),if(round(delta/1000000,0)&amp;gt;0,"+".round(delta/1000000,1)."M",round(delta/1000000,1)."M"),if((abs(delta)&amp;gt;1000),if(round(delta/1000,0)&amp;gt;0,"+".round(delta/1000,1)."K",round(delta/1000,1)."K"),if(round(delta,2)&amp;gt;0,"+".round(delta,2),round(delta,2))))."/".delta_perc."%)" 
| table Group, result 
| rename result AS "Val1"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: I have not validate the fieldformat command, I assume that is giving correct results.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Sep 2016 12:15:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Not-able-to-use-Fields-Rename-Table-command-after-Fieldformat/m-p/275479#M83094</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-09-13T12:15:43Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to use Fields, Rename, Table command after Fieldformat command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Not-able-to-use-Fields-Rename-Table-command-after-Fieldformat/m-p/275480#M83095</link>
      <description>&lt;P&gt;Thanks for your effort and revert.&lt;/P&gt;

&lt;P&gt;The above search query also not working.&lt;/P&gt;

&lt;P&gt;The result is the way if the below is removed&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| table Group, new &lt;BR /&gt;
 | rename new AS "Val1"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;So again the problem reaches the same point, wherein once the table or even just the rename command is used the formatting of &lt;STRONG&gt;new&lt;/STRONG&gt; done using fieldformat command is lost and the value is empty.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Sep 2016 12:39:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Not-able-to-use-Fields-Rename-Table-command-after-Fieldformat/m-p/275480#M83095</guid>
      <dc:creator>ashish9433</dc:creator>
      <dc:date>2016-09-13T12:39:43Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to use Fields, Rename, Table command after Fieldformat command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Not-able-to-use-Fields-Rename-Table-command-after-Fieldformat/m-p/275481#M83096</link>
      <description>&lt;P&gt;Does it work if you remove the fieldformat? &lt;/P&gt;</description>
      <pubDate>Tue, 13 Sep 2016 19:26:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Not-able-to-use-Fields-Rename-Table-command-after-Fieldformat/m-p/275481#M83096</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-09-13T19:26:29Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to use Fields, Rename, Table command after Fieldformat command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Not-able-to-use-Fields-Rename-Table-command-after-Fieldformat/m-p/275482#M83097</link>
      <description>&lt;P&gt;Yes, instead of fieldformat, if i use eval the result is proper.&lt;BR /&gt;
But again due to eval i am not able sort, which fieldformat is able to give me.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2016 05:49:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Not-able-to-use-Fields-Rename-Table-command-after-Fieldformat/m-p/275482#M83097</guid>
      <dc:creator>ashish9433</dc:creator>
      <dc:date>2016-09-15T05:49:19Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to use Fields, Rename, Table command after Fieldformat command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Not-able-to-use-Fields-Rename-Table-command-after-Fieldformat/m-p/275483#M83098</link>
      <description>&lt;P&gt;What are you sorting on? It appears the &lt;CODE&gt;fieldformat&lt;/CODE&gt; command is giving an error becuase of the complexiity. Try simplifying it. Ideally, you should do all your sorting BEFORE and then use &lt;CODE&gt;eval&lt;/CODE&gt; to format for display. If you share you entire search, I can help. But now it is unclear what fields you are using and one you are not. &lt;/P&gt;

&lt;P&gt;Also, you should consider using &lt;CODE&gt;case&lt;/CODE&gt; instead of &lt;CODE&gt;if&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2016 13:01:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Not-able-to-use-Fields-Rename-Table-command-after-Fieldformat/m-p/275483#M83098</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-09-15T13:01:12Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to use Fields, Rename, Table command after Fieldformat command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Not-able-to-use-Fields-Rename-Table-command-after-Fieldformat/m-p/275484#M83099</link>
      <description>&lt;P&gt;if i sort before and then use eval command, then in that case definetly it will show in sorted format. But as i have mentioned in the question as well, if i click on the field name then the sorting happens as a string because it contains Letters and special characters. Whereas if i use fieldformat, then it works exactly the way i want.&lt;/P&gt;

&lt;P&gt;The problem with fieldformat is, it works only when it is the last command in the search query. Incase if try to use fields command or even table command, the value formatted with fieldformat command becomes empty and hence the issue.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2016 05:07:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Not-able-to-use-Fields-Rename-Table-command-after-Fieldformat/m-p/275484#M83099</guid>
      <dc:creator>ashish9433</dc:creator>
      <dc:date>2016-09-16T05:07:50Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to use Fields, Rename, Table command after Fieldformat command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Not-able-to-use-Fields-Rename-Table-command-after-Fieldformat/m-p/275485#M83100</link>
      <description>&lt;P&gt;Check this link, &lt;A href="https://answers.splunk.com/answers/63730/using-fieldformat-and-rename.html"&gt;https://answers.splunk.com/answers/63730/using-fieldformat-and-rename.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;It seems that there is a bug or may be splunk has purposely made it that way!&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2016 05:17:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Not-able-to-use-Fields-Rename-Table-command-after-Fieldformat/m-p/275485#M83100</guid>
      <dc:creator>ashish9433</dc:creator>
      <dc:date>2016-09-16T05:17:11Z</dc:date>
    </item>
  </channel>
</rss>

