<?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 to rename dynamic column name? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-rename-dynamic-column-name/m-p/468019#M147136</link>
    <description>&lt;P&gt;Hi @jiaqya,&lt;BR /&gt;
try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=wineventlog
| timechart count
| eval _time=if(strftime(_time,"%Y-%m-%d")=strftime(now(),"%Y-%m-%d"),"Today",_time)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
    <pubDate>Thu, 06 Feb 2020 11:31:24 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2020-02-06T11:31:24Z</dc:date>
    <item>
      <title>How to rename dynamic column name?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-rename-dynamic-column-name/m-p/468018#M147135</link>
      <description>&lt;P&gt;i have a dynamic column which is bascially today's date, but the column name is 05-02-2020 for example.&lt;BR /&gt;
i would like to change this column name to "Today"&lt;/P&gt;

&lt;P&gt;unfortunately the output of the query i am getting this column name like the date...&lt;/P&gt;

&lt;P&gt;can you suggest a way to rename this column name which is dynamic for each day as "Today"&lt;/P&gt;

&lt;P&gt;if i try , |rename "05-02-2020" as Today  it works, but the date changes tomorrow....&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2020 11:14:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-rename-dynamic-column-name/m-p/468018#M147135</guid>
      <dc:creator>jiaqya</dc:creator>
      <dc:date>2020-02-06T11:14:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to rename dynamic column name?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-rename-dynamic-column-name/m-p/468019#M147136</link>
      <description>&lt;P&gt;Hi @jiaqya,&lt;BR /&gt;
try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=wineventlog
| timechart count
| eval _time=if(strftime(_time,"%Y-%m-%d")=strftime(now(),"%Y-%m-%d"),"Today",_time)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2020 11:31:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-rename-dynamic-column-name/m-p/468019#M147136</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-02-06T11:31:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to rename dynamic column name?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-rename-dynamic-column-name/m-p/468020#M147137</link>
      <description>&lt;P&gt;@jiaqya &lt;/P&gt;

&lt;P&gt;Not sure about the rename dynamic field. But I can help you in creating Today field with dynamic value.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;YOUR_SEARCH  | eval Today=""
| foreach * [ eval tm=strftime(now(),"%d-%m-%Y"), Today=if("&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"==tm,'&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;',Today) ] | fields - tm
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Sample search&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults count=7 | eval a=1 | accum a | eval col="0".a."-02-2020" | eval {col}="My Value".a | fields - _time, col, a | stats values(*) as *
| rename comment as "Upto this is for data generation only" | eval Today=""
| foreach * [ eval tm=strftime(now(),"%d-%m-%Y"), Today=if("&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"==tm,'&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;',Today) ] | fields - tm
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2020 11:51:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-rename-dynamic-column-name/m-p/468020#M147137</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2020-02-06T11:51:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to rename dynamic column name?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-rename-dynamic-column-name/m-p/468021#M147138</link>
      <description>&lt;P&gt;Kamlesh, thanks , this is perfect. just couple more queries &lt;/P&gt;

&lt;P&gt;how do i remove the matching column which is not "Today" , since there are 2 columns now, the actual date and Today..&lt;/P&gt;

&lt;P&gt;and the Today column has gone to the end, how do i bring it as 1st column as i want the recent data to be in the begining..&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2020 12:00:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-rename-dynamic-column-name/m-p/468021#M147138</guid>
      <dc:creator>jiaqya</dc:creator>
      <dc:date>2020-02-06T12:00:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to rename dynamic column name?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-rename-dynamic-column-name/m-p/468022#M147139</link>
      <description>&lt;P&gt;this was even better...&lt;BR /&gt;
This renamed the date column to Today and also retained its position in the table.&lt;BR /&gt;
thank you..&lt;/P&gt;

&lt;P&gt;this is what got me working..&lt;/P&gt;

&lt;P&gt;|eval column=if(strftime(relative_time(now(), "-1d"), "%b %d %Y")=column,"Today",column)&lt;/P&gt;

&lt;P&gt;below is the output , it replaced "Feb 05 2020" with Today&lt;/P&gt;

&lt;P&gt;Type    Today   Feb 04 2020 Feb 03 2020 Feb 02 2020 Feb 01 2020 Jan 31 2020 Jan 30 2020 Jan 28 2020 Jan 26 2020&lt;BR /&gt;
Oracle Monitoring   NA  NA  NA  NA  NA  NA  NA  NA  0&lt;BR /&gt;
Oracle Password     1   2   NA  NA  NA  NA  NA  NA  NA&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2020 12:17:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-rename-dynamic-column-name/m-p/468022#M147139</guid>
      <dc:creator>jiaqya</dc:creator>
      <dc:date>2020-02-06T12:17:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to rename dynamic column name?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-rename-dynamic-column-name/m-p/468023#M147140</link>
      <description>&lt;P&gt;@jiaqya&lt;/P&gt;

&lt;P&gt;I'm working on how to hide &lt;CODE&gt;actual date&lt;/CODE&gt; column. And you can bring &lt;CODE&gt;Today&lt;/CODE&gt; first and rest of after by adding below search.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| table Today *&lt;/CODE&gt; &lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2020 12:28:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-rename-dynamic-column-name/m-p/468023#M147140</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2020-02-06T12:28:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to rename dynamic column name?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-rename-dynamic-column-name/m-p/468024#M147141</link>
      <description>&lt;P&gt;Kamlesh, i got the issue fixed by suggestion from gcusello.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2020 12:29:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-rename-dynamic-column-name/m-p/468024#M147141</guid>
      <dc:creator>jiaqya</dc:creator>
      <dc:date>2020-02-06T12:29:45Z</dc:date>
    </item>
  </channel>
</rss>

