<?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: Copy a row in a table in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Copy-a-row-in-a-table/m-p/473517#M192381</link>
    <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval _raw="Date,ID,Type,Duration
2019-11-22,ABC,XYZ,4
2019-11-26,BCD,YZX,2"
| multikv
| table Date,ID,Type,Duration
| rename COMMENT as "this is the sample you provide"
| rename COMMENT as "From here, the logic"
| eval Date=strptime(Date,"%F")
| eval Date_after = relative_time(Date,"+".(Duration - 1)."d")
| eval Date=mvappend(Date,Date_after)
| mvexpand Date
| rename Date as _time
| timechart span=1d values(*) as *
| rename _time as Date
| table Date,ID,Type,Duration
| filldown ID, Type
| reverse
| streamstats count as Duration by ID
| reverse
| fieldformat Date=strftime(Date,"%F")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hi, @komalg&lt;BR /&gt;
How about this?&lt;/P&gt;</description>
    <pubDate>Tue, 31 Dec 2019 00:09:19 GMT</pubDate>
    <dc:creator>to4kawa</dc:creator>
    <dc:date>2019-12-31T00:09:19Z</dc:date>
    <item>
      <title>Copy a row in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Copy-a-row-in-a-table/m-p/473514#M192378</link>
      <description>&lt;P&gt;Hi, I am trying to conditionally add records to my table with a slight modification to the data. for example&lt;BR /&gt;
Date              ID        Type     Duration&lt;BR /&gt;
2019-11-22  ABC    XYZ      4&lt;BR /&gt;
2019-11-26  BCD    YZX      2&lt;/P&gt;

&lt;P&gt;So for this record I am trying to add data to my table like &lt;BR /&gt;
Date              ID        Type     Duration&lt;BR /&gt;
2019-11-22  ABC    XYZ      4&lt;BR /&gt;
2019-11-23  ABC    XYZ      3 -- Add new row &lt;BR /&gt;
2019-11-24  ABC    XYZ      2 -- Add new row &lt;BR /&gt;
2019-11-25  ABC    XYZ      1 -- Add new row &lt;BR /&gt;
2019-11-26  BCD    YZX      2 -- Add new row &lt;BR /&gt;
2019-11-27  BCD    YZX      1 -- Add new row &lt;/P&gt;

&lt;P&gt;Any pointers on this?&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Dec 2019 16:42:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Copy-a-row-in-a-table/m-p/473514#M192378</guid>
      <dc:creator>komalg</dc:creator>
      <dc:date>2019-12-30T16:42:42Z</dc:date>
    </item>
    <item>
      <title>Re: Copy a row in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Copy-a-row-in-a-table/m-p/473515#M192379</link>
      <description>&lt;P&gt;A Splunk Table is a visualization of data returned by a search, they do not persist beyond the "viewable" use of the original search. If the table is to be refreshed with new data, a new search is used to pull fresh results for the visualization. &lt;/P&gt;

&lt;P&gt;Perhaps you mean a lookuptable, which looks and feels like a spreadsheet and it persists beyond the presentation of the search results.&lt;/P&gt;

&lt;P&gt;Here is the SPL for a table result if all the fields in the example are already extracted:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;        index=your_index sourcetype=your_sourcetype Date=* ID=* Type=* Duration=* | table Date ID Type Duration
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here is the SPL to create or append results in a lookuptable (make sure the lookuptable name ends in .csv):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   index=your_index sourcetype=your_sourcetype Date=* ID=* Type=* Duration=* 
    | outputlookup append=true your_lookup_name.csv
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you want to view the lookuptable after it has been populated, here is the SPL:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|inputlookup your_lookup_name.csv
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Dec 2019 18:49:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Copy-a-row-in-a-table/m-p/473515#M192379</guid>
      <dc:creator>mydog8it</dc:creator>
      <dc:date>2019-12-30T18:49:03Z</dc:date>
    </item>
    <item>
      <title>Re: Copy a row in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Copy-a-row-in-a-table/m-p/473516#M192380</link>
      <description>&lt;P&gt;Where does this new data come from?&lt;/P&gt;</description>
      <pubDate>Mon, 30 Dec 2019 19:44:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Copy-a-row-in-a-table/m-p/473516#M192380</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-12-30T19:44:00Z</dc:date>
    </item>
    <item>
      <title>Re: Copy a row in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Copy-a-row-in-a-table/m-p/473517#M192381</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval _raw="Date,ID,Type,Duration
2019-11-22,ABC,XYZ,4
2019-11-26,BCD,YZX,2"
| multikv
| table Date,ID,Type,Duration
| rename COMMENT as "this is the sample you provide"
| rename COMMENT as "From here, the logic"
| eval Date=strptime(Date,"%F")
| eval Date_after = relative_time(Date,"+".(Duration - 1)."d")
| eval Date=mvappend(Date,Date_after)
| mvexpand Date
| rename Date as _time
| timechart span=1d values(*) as *
| rename _time as Date
| table Date,ID,Type,Duration
| filldown ID, Type
| reverse
| streamstats count as Duration by ID
| reverse
| fieldformat Date=strftime(Date,"%F")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hi, @komalg&lt;BR /&gt;
How about this?&lt;/P&gt;</description>
      <pubDate>Tue, 31 Dec 2019 00:09:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Copy-a-row-in-a-table/m-p/473517#M192381</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2019-12-31T00:09:19Z</dc:date>
    </item>
  </channel>
</rss>

