<?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 merge different values ​​based on one field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-different-values-based-on-one-field/m-p/401257#M116173</link>
    <description>&lt;P&gt;@jinnypt,&lt;/P&gt;

&lt;P&gt;Does this work for you ?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"your search terms for getting the fields "
| streamstats current=f window=1 last(at) as prev_at, last(bt) as prev_bt,last(ct) as prev_ct,count as rownum by name reset_on_change=true
| eval at=coalesce(at,prev_at),bt=coalesce(bt,prev_bt),ct=coalesce(ct,prev_ct)
| eval a=if(at=="ok","Y","N"),b=if(bt=="ok","Y","N"),c=if(ct=="ok","Y","N")
| where rownum=1
| table name,a,b,c,at,bt,ct
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or run anywhere example with &lt;CODE&gt;if&lt;/CODE&gt; instead of coalesce in case you have "" instead of a null value&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval name="1,1,2,2"| makemv delim="," name
| eval a="N,Y,Y,N"| makemv delim="," a| eval b="Y,N,N,N"| makemv delim="," b| eval c="N,N,N,Y"| makemv delim="," c
| eval at="nil,ok,ok,nil"| makemv delim="," at|eval bt="ok,nil,nil,nil"| makemv delim="," bt
| eval ct="nil,nil,nil,ok"| makemv delim="," ct
| eval t=mvzip(mvzip(mvzip(mvzip(mvzip(mvzip(name,a,"#"),b,"#"),c,"#"),at,"#"),bt,"#"),ct,"#")
| table t| mvexpand t| eval z=split(t,"#")
| eval name=mvindex(z,0),a=mvindex(z,1),b=mvindex(z,2),c=mvindex(z,3),at=mvindex(z,4),bt=mvindex(z,5),ct=mvindex(z,6)
| fields name,a,b,c,at,bt,ct| replace nil with ""
| eval _COMMENTS="=-=-=-=-=-=-=-=-=UNTIL HERE IS DUMMY DATA GENERATION AND NOTHING HAS TO DO WITH ACTUAL SEARCH =-=-=-="
   | streamstats current=f window=1 last(at) as prev_at, last(bt) as prev_bt,last(ct) as prev_ct,
      count as rownum by name reset_on_change=true
   | where rownum=1
   | eval at=if(at="",prev_at,at),bt=if(bt="",prev_bt,bt),ct=if(ct="",prev_ct,ct)
   | eval a=if(at=="ok","Y","N"),b=if(bt=="ok","Y","N"),c=if(ct=="ok","Y","N")
   | table name,a,b,c,at,bt,ct
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 14 Aug 2018 16:10:16 GMT</pubDate>
    <dc:creator>renjith_nair</dc:creator>
    <dc:date>2018-08-14T16:10:16Z</dc:date>
    <item>
      <title>How to merge different values ​​based on one field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-different-values-based-on-one-field/m-p/401256#M116172</link>
      <description>&lt;P&gt;I have a table like this one, and I want to know how to merge different values ​​based on one field.&lt;/P&gt;

&lt;P&gt;example table)&lt;/P&gt;

&lt;P&gt;[AS-IS]&lt;BR /&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/5536i6752A80D90E166FE/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;[TO-BE]&lt;BR /&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/5537i0EB1EA0D6A24A986/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;ps. a/b/c is the value when at/bt/ct is "Y"&lt;/P&gt;</description>
      <pubDate>Tue, 14 Aug 2018 06:44:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-different-values-based-on-one-field/m-p/401256#M116172</guid>
      <dc:creator>jinnypt</dc:creator>
      <dc:date>2018-08-14T06:44:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge different values ​​based on one field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-different-values-based-on-one-field/m-p/401257#M116173</link>
      <description>&lt;P&gt;@jinnypt,&lt;/P&gt;

&lt;P&gt;Does this work for you ?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"your search terms for getting the fields "
| streamstats current=f window=1 last(at) as prev_at, last(bt) as prev_bt,last(ct) as prev_ct,count as rownum by name reset_on_change=true
| eval at=coalesce(at,prev_at),bt=coalesce(bt,prev_bt),ct=coalesce(ct,prev_ct)
| eval a=if(at=="ok","Y","N"),b=if(bt=="ok","Y","N"),c=if(ct=="ok","Y","N")
| where rownum=1
| table name,a,b,c,at,bt,ct
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or run anywhere example with &lt;CODE&gt;if&lt;/CODE&gt; instead of coalesce in case you have "" instead of a null value&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval name="1,1,2,2"| makemv delim="," name
| eval a="N,Y,Y,N"| makemv delim="," a| eval b="Y,N,N,N"| makemv delim="," b| eval c="N,N,N,Y"| makemv delim="," c
| eval at="nil,ok,ok,nil"| makemv delim="," at|eval bt="ok,nil,nil,nil"| makemv delim="," bt
| eval ct="nil,nil,nil,ok"| makemv delim="," ct
| eval t=mvzip(mvzip(mvzip(mvzip(mvzip(mvzip(name,a,"#"),b,"#"),c,"#"),at,"#"),bt,"#"),ct,"#")
| table t| mvexpand t| eval z=split(t,"#")
| eval name=mvindex(z,0),a=mvindex(z,1),b=mvindex(z,2),c=mvindex(z,3),at=mvindex(z,4),bt=mvindex(z,5),ct=mvindex(z,6)
| fields name,a,b,c,at,bt,ct| replace nil with ""
| eval _COMMENTS="=-=-=-=-=-=-=-=-=UNTIL HERE IS DUMMY DATA GENERATION AND NOTHING HAS TO DO WITH ACTUAL SEARCH =-=-=-="
   | streamstats current=f window=1 last(at) as prev_at, last(bt) as prev_bt,last(ct) as prev_ct,
      count as rownum by name reset_on_change=true
   | where rownum=1
   | eval at=if(at="",prev_at,at),bt=if(bt="",prev_bt,bt),ct=if(ct="",prev_ct,ct)
   | eval a=if(at=="ok","Y","N"),b=if(bt=="ok","Y","N"),c=if(ct=="ok","Y","N")
   | table name,a,b,c,at,bt,ct
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Aug 2018 16:10:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-different-values-based-on-one-field/m-p/401257#M116173</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2018-08-14T16:10:16Z</dc:date>
    </item>
  </channel>
</rss>

