<?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: Dynamic Table header by incremental values. in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Dynamic-Table-header-by-incremental-values/m-p/492620#M46013</link>
    <description>&lt;P&gt;Hi niketnilay,&lt;/P&gt;

&lt;P&gt;Please find the actual problem below:&lt;BR /&gt;
With limit=0 in chart , the chart displays all the available values of taken_date in each row by hostname.&lt;BR /&gt;
The header will have the corresponding taken_date value for each column.&lt;BR /&gt;
But I would like to display 30 columns (limit=30) . Columns header should be in descending order of taken_date.&lt;BR /&gt;
Now unlimited columns are displayed from oldest of taken_date to the latest of the taken_date .&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Current search with problem:
base search from JSON..
| eval row1=strptime(taken_date,"%b %d %Y %H:%M:%S:%3N%p")
| eval col1=strptime(taken_date,"%b %d %Y %H:%M:%S")
| chart limit=0 values(row1) as date1 by hostname col1 
| fillnull value=NULL
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So from the below query, i am trying  to get 30 days older to latest value of taken_date in chart.&lt;BR /&gt;
Here the latest of taken_date can be a week old. The 30 days old date can six months old.&lt;BR /&gt;
The date&amp;amp;time functions which work only on _time and current time(now()) etc, would not work in this  context. &lt;/P&gt;

&lt;P&gt;In the below query i am expecting the values from 30 days old of taken_date to latest of taken_date.&lt;BR /&gt;
30 days old date is derived by substracting 30 days from latest of taken_date.&lt;BR /&gt;
latest of taken_date can be a week old,2 weeks old or any.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search from JSON..
| eval row1=strptime(taken_date,"%b %d %Y %H:%M:%S:%3N%p")
| eval col1=strptime(taken_date,"%b %d %Y %H:%M:%S")
| stats max(row1) as max_row1 by row1 hostname max(col1) as max_col1 by col1
| eval max_row1_30= max_row1-2629743 
| eval max_col1_30= max_col1-2629743 
| where row1 &amp;gt; max_row1_30 AND where col1 &amp;gt; max_col1_30
| chart limit=0 values(row1) as date1 by hostname col1 
| fillnull value=NULL
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thank you.&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 05:28:54 GMT</pubDate>
    <dc:creator>email2vamsi</dc:creator>
    <dc:date>2020-09-30T05:28:54Z</dc:date>
    <item>
      <title>Dynamic Table header by incremental values.</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Dynamic-Table-header-by-incremental-values/m-p/492611#M46004</link>
      <description>&lt;P&gt;Hello Experts,&lt;/P&gt;

&lt;P&gt;I have attached two images.&lt;BR /&gt;
The following search returns results as shown in "CURRENT" image.&lt;BR /&gt;
But i would like to have results as per "DESIRED" image.&lt;BR /&gt;
Could you please help.&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;base search from JSON..&lt;BR /&gt;
 | stats values(date1) by hostname &lt;BR /&gt;
| rename  values(date1) AS date1 &lt;BR /&gt;
| stats list(hostname) AS hostname by date1&lt;BR /&gt;
| xyseries hostname date1 date1&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/8847i3A5485740BDEBF7E/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;BR /&gt;
Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 08 May 2020 09:55:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Dynamic-Table-header-by-incremental-values/m-p/492611#M46004</guid>
      <dc:creator>email2vamsi</dc:creator>
      <dc:date>2020-05-08T09:55:38Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Table header by incremental values.</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Dynamic-Table-header-by-incremental-values/m-p/492612#M46005</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;base search from JSON..
| stats values(_time) as date1 by hostname
| eval counter=mvrange(1,mvcount(date1)+1)
| mvexpand counter
| eval col{counter}=mvindex(date1,counter-1)
| stats values(*) as * by hostname
| foreach col* [eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=strftime('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;',"%F %T")]
| fields - counter date1
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 May 2020 10:45:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Dynamic-Table-header-by-incremental-values/m-p/492612#M46005</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-05-08T10:45:42Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Table header by incremental values.</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Dynamic-Table-header-by-incremental-values/m-p/492613#M46006</link>
      <description>&lt;P&gt;Each date value should come in a separate column as shown in the "DESIRED" image above.&lt;BR /&gt;
Your query is showing all the dates in once single column.&lt;BR /&gt;
Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 08 May 2020 11:14:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Dynamic-Table-header-by-incremental-values/m-p/492613#M46006</guid>
      <dc:creator>email2vamsi</dc:creator>
      <dc:date>2020-05-08T11:14:42Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Table header by incremental values.</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Dynamic-Table-header-by-incremental-values/m-p/492614#M46007</link>
      <description>&lt;P&gt;I see. check update my answer&lt;/P&gt;</description>
      <pubDate>Fri, 08 May 2020 12:18:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Dynamic-Table-header-by-incremental-values/m-p/492614#M46007</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-05-08T12:18:44Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Table header by incremental values.</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Dynamic-Table-header-by-incremental-values/m-p/492615#M46008</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
Your query returns all the dates in header and all hotnames in one single long row.&lt;BR /&gt;
It wouldn't suit the requirement.&lt;/P&gt;

&lt;P&gt;As shown in the "DESIRED" image of the original message,i  would like to have all hostname is first column and later followed by dates columns. The column header for dates should be like col1,col2,col3 etc generated dynamically based on count of dates.&lt;/P&gt;

&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 08 May 2020 17:29:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Dynamic-Table-header-by-incremental-values/m-p/492615#M46008</guid>
      <dc:creator>email2vamsi</dc:creator>
      <dc:date>2020-05-08T17:29:28Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Table header by incremental values.</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Dynamic-Table-header-by-incremental-values/m-p/492616#M46009</link>
      <description>&lt;P&gt;Sorry, I'm not going to do the quiz, so please fix it.&lt;/P&gt;</description>
      <pubDate>Fri, 08 May 2020 22:50:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Dynamic-Table-header-by-incremental-values/m-p/492616#M46009</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-05-08T22:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Table header by incremental values.</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Dynamic-Table-header-by-incremental-values/m-p/492617#M46010</link>
      <description>&lt;P&gt;@email2vamsi as per the data/details provided seems like your use case is that &lt;CODE&gt;Daily you will have one host reported only once and you want per host the time at which the host reported daily.&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;If the above is your use case, can you try the following&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search from JSON..
| eval Col=strftime(_time,"%Y-%m-%d"),date1=strftime(_time,"%Y-%m-%d %H:%M:%S")
| chart latest(date1) as date1 by hostname Col
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Following is a run anywhere search based on Splunk's _internal index:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal sourcetype=splunkd
| eval Col=strftime(_time,"%Y-%m-%d"),date1=strftime(_time,"%Y-%m-%d %H:%M:%S")
| chart latest(date1) as date1 by log_level Col
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please try out and confirm!&lt;/P&gt;</description>
      <pubDate>Mon, 11 May 2020 09:58:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Dynamic-Table-header-by-incremental-values/m-p/492617#M46010</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-05-11T09:58:57Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Table header by incremental values.</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Dynamic-Table-header-by-incremental-values/m-p/492618#M46011</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Thank you for your reply.&lt;BR /&gt;
As shown in the image in my original post, i want to transform results from "PRESENT" to "DESIRED".&lt;BR /&gt;
There will will 100's of hostname and each hostname  will be have date entries for 30 days.&lt;BR /&gt;
Each host can have date/time from same day and for the last 30 days needs to fetched and showed in the in "DESIRED" format.&lt;/P&gt;

&lt;P&gt;If a hostname has 45 dates for the last 30 days, then we need to generate 45 columns dynamically .&lt;/P&gt;

&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 11 May 2020 10:47:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Dynamic-Table-header-by-incremental-values/m-p/492618#M46011</guid>
      <dc:creator>email2vamsi</dc:creator>
      <dc:date>2020-05-11T10:47:29Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Table header by incremental values.</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Dynamic-Table-header-by-incremental-values/m-p/492619#M46012</link>
      <description>&lt;P&gt;@email2vamsi your comment above &lt;CODE&gt;If a hostname has 45 dates for the last 30 days&lt;/CODE&gt; is not obvious as per the original question or screenshot. More than one event per host per day means you will have multi-value result.&lt;/P&gt;

&lt;P&gt;All you need to change in my query is &lt;CODE&gt;latest(date1)&lt;/CODE&gt; should be changed with &lt;CODE&gt;values(date1)&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Also whether you have 1 host, 100s or 1000s or more hosts they will be handled by &lt;CODE&gt;by hostname&lt;/CODE&gt; clause of &lt;CODE&gt;chart&lt;/CODE&gt; command.&lt;/P&gt;

&lt;P&gt;On second note, using Col as the Date, you will always have 1 column per day, if you query last 30 days you will get 30 columns and if you query last 7 days you will get 7 columns.&lt;/P&gt;

&lt;P&gt;Just change &lt;CODE&gt;latest()&lt;/CODE&gt; aggregation with &lt;CODE&gt;values()&lt;/CODE&gt; aggregation in my comment above and confirm if your issue is resolved.&lt;/P&gt;</description>
      <pubDate>Mon, 11 May 2020 11:18:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Dynamic-Table-header-by-incremental-values/m-p/492619#M46012</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-05-11T11:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Table header by incremental values.</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Dynamic-Table-header-by-incremental-values/m-p/492620#M46013</link>
      <description>&lt;P&gt;Hi niketnilay,&lt;/P&gt;

&lt;P&gt;Please find the actual problem below:&lt;BR /&gt;
With limit=0 in chart , the chart displays all the available values of taken_date in each row by hostname.&lt;BR /&gt;
The header will have the corresponding taken_date value for each column.&lt;BR /&gt;
But I would like to display 30 columns (limit=30) . Columns header should be in descending order of taken_date.&lt;BR /&gt;
Now unlimited columns are displayed from oldest of taken_date to the latest of the taken_date .&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Current search with problem:
base search from JSON..
| eval row1=strptime(taken_date,"%b %d %Y %H:%M:%S:%3N%p")
| eval col1=strptime(taken_date,"%b %d %Y %H:%M:%S")
| chart limit=0 values(row1) as date1 by hostname col1 
| fillnull value=NULL
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So from the below query, i am trying  to get 30 days older to latest value of taken_date in chart.&lt;BR /&gt;
Here the latest of taken_date can be a week old. The 30 days old date can six months old.&lt;BR /&gt;
The date&amp;amp;time functions which work only on _time and current time(now()) etc, would not work in this  context. &lt;/P&gt;

&lt;P&gt;In the below query i am expecting the values from 30 days old of taken_date to latest of taken_date.&lt;BR /&gt;
30 days old date is derived by substracting 30 days from latest of taken_date.&lt;BR /&gt;
latest of taken_date can be a week old,2 weeks old or any.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search from JSON..
| eval row1=strptime(taken_date,"%b %d %Y %H:%M:%S:%3N%p")
| eval col1=strptime(taken_date,"%b %d %Y %H:%M:%S")
| stats max(row1) as max_row1 by row1 hostname max(col1) as max_col1 by col1
| eval max_row1_30= max_row1-2629743 
| eval max_col1_30= max_col1-2629743 
| where row1 &amp;gt; max_row1_30 AND where col1 &amp;gt; max_col1_30
| chart limit=0 values(row1) as date1 by hostname col1 
| fillnull value=NULL
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 05:28:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Dynamic-Table-header-by-incremental-values/m-p/492620#M46013</guid>
      <dc:creator>email2vamsi</dc:creator>
      <dc:date>2020-09-30T05:28:54Z</dc:date>
    </item>
  </channel>
</rss>

