<?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 replace value with another field values in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/how-to-replace-value-with-another-field-values/m-p/686489#M234169</link>
    <description>&lt;P&gt;Use streamstats. Here's an example - use the last 3 lines with your data&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults format=csv data="ID,message,state
101,executed,started
101,null,in progress
101,none,completed
102,activity printed,started
102,null,in progress
102,activity printed,completed"
| eval needs_fill=if(message="executed" AND state="started", 1, 0)
| streamstats max(needs_fill) as needs_fill by ID
| eval message=if(needs_fill=1 AND state="completed", "executed", message)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 06 May 2024 04:47:12 GMT</pubDate>
    <dc:creator>bowesmana</dc:creator>
    <dc:date>2024-05-06T04:47:12Z</dc:date>
    <item>
      <title>how to replace value with another field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-replace-value-with-another-field-values/m-p/686451#M234162</link>
      <description>&lt;P&gt;Hi, we could see message ="executed" for started state field. so, would like to replace with same massage where state="completed"&amp;nbsp; event too for same ID's.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="james_n_0-1714933100551.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/30676i8CB7D0E969696C40/image-size/medium?v=v2&amp;amp;px=400" role="button" title="james_n_0-1714933100551.png" alt="james_n_0-1714933100551.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I hope I word this out clearly. Thank you in advance.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 05 May 2024 18:27:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-replace-value-with-another-field-values/m-p/686451#M234162</guid>
      <dc:creator>james_n</dc:creator>
      <dc:date>2024-05-05T18:27:19Z</dc:date>
    </item>
    <item>
      <title>Re: how to replace value with another field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-replace-value-with-another-field-values/m-p/686457#M234163</link>
      <description>&lt;P&gt;Is the logic that IFF there is a previous message=executed for ID X, then if state=completed, message should then be changed to 'executed' or should it always be executed if state=completed?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval message=if(state="completed", "executed", message)&lt;/LI-CODE&gt;&lt;P&gt;will just change message toexecuted if state is&amp;nbsp;completed.&lt;/P&gt;&lt;P&gt;If you ONLY want to change&amp;nbsp;completed to&amp;nbsp;executed if there is a previous "started", then it is important to understand your data a bit better, as ordering becomes significant - you have&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;started&lt;/LI&gt;&lt;LI&gt;completed&lt;/LI&gt;&lt;LI&gt;pending&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;for ID 101 - so I am guessing that those are not in the order of occurrence.&lt;/P&gt;&lt;P&gt;You would look at using streamstats, stats, eventstats or transaction to solve this - but can you give more about your existing search an data&lt;/P&gt;</description>
      <pubDate>Sun, 05 May 2024 22:19:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-replace-value-with-another-field-values/m-p/686457#M234163</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2024-05-05T22:19:16Z</dc:date>
    </item>
    <item>
      <title>Re: how to replace value with another field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-replace-value-with-another-field-values/m-p/686488#M234168</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;thanks for your quick response,&lt;/P&gt;&lt;P&gt;the value of massage field is different as per ID as you shown below.&lt;BR /&gt;current data:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="james_n_0-1714969674437.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/30683iCA4D5D3BABB72BAB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="james_n_0-1714969674437.png" alt="james_n_0-1714969674437.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;expected output:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="james_n_1-1714969800264.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/30684iD520CD35C5ADFC1B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="james_n_1-1714969800264.png" alt="james_n_1-1714969800264.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 May 2024 04:31:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-replace-value-with-another-field-values/m-p/686488#M234168</guid>
      <dc:creator>james_n</dc:creator>
      <dc:date>2024-05-06T04:31:06Z</dc:date>
    </item>
    <item>
      <title>Re: how to replace value with another field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-replace-value-with-another-field-values/m-p/686489#M234169</link>
      <description>&lt;P&gt;Use streamstats. Here's an example - use the last 3 lines with your data&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults format=csv data="ID,message,state
101,executed,started
101,null,in progress
101,none,completed
102,activity printed,started
102,null,in progress
102,activity printed,completed"
| eval needs_fill=if(message="executed" AND state="started", 1, 0)
| streamstats max(needs_fill) as needs_fill by ID
| eval message=if(needs_fill=1 AND state="completed", "executed", message)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 May 2024 04:47:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-replace-value-with-another-field-values/m-p/686489#M234169</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2024-05-06T04:47:12Z</dc:date>
    </item>
    <item>
      <title>Re: how to replace value with another field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-replace-value-with-another-field-values/m-p/686490#M234170</link>
      <description>&lt;P&gt;| makeresults&lt;BR /&gt;| eval state="started"&lt;BR /&gt;| eval message="executed"&lt;BR /&gt;|eval id="101"&lt;BR /&gt;|append [| makeresults&lt;BR /&gt;| eval state="inprogess"&lt;BR /&gt;| eval message="null"&lt;BR /&gt;|eval id="101"]&lt;BR /&gt;|append [| makeresults&lt;BR /&gt;| eval state="completed"&lt;BR /&gt;| eval message="none"&lt;BR /&gt;|eval id="101"]&lt;BR /&gt;|append [| makeresults&lt;BR /&gt;| eval state="started"&lt;BR /&gt;| eval message="activity printed "&lt;BR /&gt;|eval id="102"]&lt;BR /&gt;|append [| makeresults&lt;BR /&gt;| eval state="inprogess"&lt;BR /&gt;| eval message="null"&lt;BR /&gt;|eval id="102"]&lt;BR /&gt;|append [| makeresults&lt;BR /&gt;| eval state="completed"&lt;BR /&gt;| eval message="none"&lt;BR /&gt;|eval id="102"]| eval needs_fill=if(message="executed" AND state="started", 1, 0)&lt;BR /&gt;| streamstats max(needs_fill) as needs_fill by ID&lt;BR /&gt;| eval message=if(needs_fill=1 AND state="completed", "executed", message)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;its not working as expected, as mentioned value of massage field is vary per ID's only value of state field remains same for all ID's&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 May 2024 04:58:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-replace-value-with-another-field-values/m-p/686490#M234170</guid>
      <dc:creator>james_n</dc:creator>
      <dc:date>2024-05-06T04:58:33Z</dc:date>
    </item>
    <item>
      <title>Re: how to replace value with another field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-replace-value-with-another-field-values/m-p/686495#M234173</link>
      <description>&lt;P&gt;Not sure why you are doing all those appends/makeresults - but look at your id field - the streamstats logic uses ID, not id - fields are case sensitive&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 May 2024 05:18:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-replace-value-with-another-field-values/m-p/686495#M234173</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2024-05-06T05:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: how to replace value with another field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-replace-value-with-another-field-values/m-p/686498#M234174</link>
      <description>&lt;P&gt;yes corrected its only working for where message="executed" but not where message values are different for other ID's. please be noted that massage value could be anything for IDs and values of state field are same.&lt;/P&gt;</description>
      <pubDate>Mon, 06 May 2024 05:38:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-replace-value-with-another-field-values/m-p/686498#M234174</guid>
      <dc:creator>james_n</dc:creator>
      <dc:date>2024-05-06T05:38:35Z</dc:date>
    </item>
    <item>
      <title>Re: how to replace value with another field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-replace-value-with-another-field-values/m-p/686510#M234181</link>
      <description>&lt;LI-CODE lang="markup"&gt;| makeresults format=csv data="ID,message,state
101,executed,started
101,null,in progress
101,none,completed
102,activity printed,started
102,null,in progress
102,none,completed"
| eval startedMessage=if(state=="started",message,null())
| eventstats values(startedMessage) as startedMessage by ID
| eval message=if(state=="completed", startedMessage, message)&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 06 May 2024 06:55:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-replace-value-with-another-field-values/m-p/686510#M234181</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-05-06T06:55:11Z</dc:date>
    </item>
    <item>
      <title>Re: how to replace value with another field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-replace-value-with-another-field-values/m-p/686513#M234183</link>
      <description>&lt;P&gt;The way I read your premise, this sounds like a transaction logic. &amp;nbsp;So, let me first clarify your use case.&lt;/P&gt;&lt;P&gt;You data look like&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;_time&lt;/TD&gt;&lt;TD&gt;id&lt;/TD&gt;&lt;TD&gt;message&lt;/TD&gt;&lt;TD&gt;state&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1969-12-31 16:00:00&lt;/TD&gt;&lt;TD&gt;101&lt;/TD&gt;&lt;TD&gt;executed&lt;/TD&gt;&lt;TD&gt;started&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1969-12-31 16:00:04&lt;/TD&gt;&lt;TD&gt;102&lt;/TD&gt;&lt;TD&gt;activity printed&lt;/TD&gt;&lt;TD&gt;started&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1969-12-31 16:00:09&lt;/TD&gt;&lt;TD&gt;101&lt;/TD&gt;&lt;TD&gt;null&lt;/TD&gt;&lt;TD&gt;in progress&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1969-12-31 16:00:10&lt;/TD&gt;&lt;TD&gt;102&lt;/TD&gt;&lt;TD&gt;null&lt;/TD&gt;&lt;TD&gt;in progress&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1969-12-31 16:00:18&lt;/TD&gt;&lt;TD&gt;102&lt;/TD&gt;&lt;TD&gt;none&lt;/TD&gt;&lt;TD&gt;completed&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1969-12-31 16:00:24&lt;/TD&gt;&lt;TD&gt;101&lt;/TD&gt;&lt;TD&gt;none&lt;/TD&gt;&lt;TD&gt;completed&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Note I added some time interleave between 101 and 102 to make the transaction nature more obvious. (Never mind the date is from 1969; that is just for ease of emulation.) &amp;nbsp;You want to use some results like&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;_time&lt;/TD&gt;&lt;TD&gt;duration&lt;/TD&gt;&lt;TD&gt;eventcount&lt;/TD&gt;&lt;TD&gt;id&lt;/TD&gt;&lt;TD&gt;message&lt;/TD&gt;&lt;TD&gt;state&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1969-12-31 16:00:04&lt;/TD&gt;&lt;TD&gt;14&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;102&lt;/TD&gt;&lt;TD&gt;activity printed&lt;/TD&gt;&lt;TD&gt;completed&amp;lt;-in progress&amp;lt;-started&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1969-12-31 16:00:00&lt;/TD&gt;&lt;TD&gt;24&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;101&lt;/TD&gt;&lt;TD&gt;executed&lt;/TD&gt;&lt;TD&gt;completed&amp;lt;-in progress&amp;lt;-started&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Here, I ignored the format of the expected output in your earlier comment, just want to clarify that "state" goes through "started", "in progress", and "completed" to form a transaction for each unique "id". &amp;nbsp;Your material requirement is to obtain a single value for "message" that is NEITHER "null" nor "none". &amp;nbsp;Is this correct? &amp;nbsp;The result as illustrated here can be obtained with&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| transaction id startswith="state=started" endswith="state=completed"
| eval message = mvfilter(NOT message IN ("none", "null"))
| eval state = mvjoin(state, "&amp;lt;-")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first two commands literally implements my interpretation of your intentions. &amp;nbsp;The third line is just a visual element to make state transition obvious for each .&lt;/P&gt;&lt;P&gt;In my mind, the above results table is sufficient, and is more representative of the problem. &amp;nbsp;But if you really want to list each event, like&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;_time&lt;/TD&gt;&lt;TD&gt;id&lt;/TD&gt;&lt;TD&gt;message&lt;/TD&gt;&lt;TD&gt;state&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1969-12-31 16:00:00&lt;/TD&gt;&lt;TD&gt;101&lt;/TD&gt;&lt;TD&gt;executed&lt;/TD&gt;&lt;TD&gt;started&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1969-12-31 16:00:04&lt;/TD&gt;&lt;TD&gt;102&lt;/TD&gt;&lt;TD&gt;activity printed&lt;/TD&gt;&lt;TD&gt;started&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1969-12-31 16:00:09&lt;/TD&gt;&lt;TD&gt;101&lt;/TD&gt;&lt;TD&gt;executed&lt;/TD&gt;&lt;TD&gt;in progress&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1969-12-31 16:00:10&lt;/TD&gt;&lt;TD&gt;102&lt;/TD&gt;&lt;TD&gt;activity printed&lt;/TD&gt;&lt;TD&gt;in progress&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1969-12-31 16:00:18&lt;/TD&gt;&lt;TD&gt;102&lt;/TD&gt;&lt;TD&gt;activity printed&lt;/TD&gt;&lt;TD&gt;completed&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1969-12-31 16:00:24&lt;/TD&gt;&lt;TD&gt;101&lt;/TD&gt;&lt;TD&gt;executed&lt;/TD&gt;&lt;TD&gt;completed&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;You can either use eventstats&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eventstats values(message) as message by id| eval message = mvfilter(NOT message IN ("none", "null"))
| eval message = mvfilter(NOT message IN ("none", "null"))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;or streamstats as&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;suggested&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| streamstats values(message) as message by id| eval message = mvfilter(NOT message IN ("none", "null"))
| eval message = mvfilter(NOT message IN ("none", "null"))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To emulate input, I added _time into&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;'s formula because it's just simpler.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults format=csv data="id,message,state,_time
101,executed,started,0
102,activity printed,started,4
101,null,in progress,9
102,null,in progress,10
102,none,completed,18
101,none,completed,24"
| eval _raw = "doesn't matter" ``` mock field _raw is important for transaction ```
``` data mockup above ```&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 May 2024 07:07:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-replace-value-with-another-field-values/m-p/686513#M234183</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-05-06T07:07:27Z</dc:date>
    </item>
  </channel>
</rss>

