<?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 do you change a row by checking another row? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-change-a-row-by-checking-another-row/m-p/384501#M172185</link>
    <description>&lt;P&gt;If the query field is indeed a number like this, with the basic data showing as 1 and the row to check against showing as 2, then I think this would work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... your current query...
| eventstats max(query) as max_query by Id
| eval Criticality=if(max_query=2 AND sourcetype="S2","P2",Criticality)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note: this is specific to that sourcetype and criticality values.&lt;/P&gt;

&lt;P&gt;If you need this to work more generically as if it was a lookup, it might be easier to actually store the data from query 2 into a lookup. I think a more generic solution with eventstats could look like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... your current query...
| eval CriticalityNew=if(query=2,Criticality,null())
| eventstats values(CriticalityNew) as CriticalityNew by Id,sourcetype
| eval Criticality = coalesce(CriticalityNew,Criticality)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That first eval to copy Criticality to CriticalityNew can perhaps also be achieved by adjusting your current query, such that for rows from query2 the Criticality field is called CriticalityNew.&lt;/P&gt;

&lt;P&gt;Otherwise, a solution using join might work as well:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...query 1...
| join type=left Id, sourcetype [
search ...query 2...
| mvexpand Id
| rename Criticality as CriticalityNew
| table Id, sourcetype,CriticalityNew
]
| eval Criticality = coalesce(CriticalityNew,Criticality)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 01 Apr 2019 09:43:11 GMT</pubDate>
    <dc:creator>FrankVl</dc:creator>
    <dc:date>2019-04-01T09:43:11Z</dc:date>
    <item>
      <title>How do you change a row by checking another row?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-change-a-row-by-checking-another-row/m-p/384491#M172175</link>
      <description>&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/6801i84A346AEB76038A6/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;Hi Team,&lt;/P&gt;

&lt;P&gt;In the screenshot below, I want to change the criticality of sorcetype S2 to P2(row 3) if its Id is available in the 4th Column.&lt;/P&gt;

&lt;P&gt;Keeping all the other values same.&lt;/P&gt;

&lt;P&gt;Plz help.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Mar 2019 08:24:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-change-a-row-by-checking-another-row/m-p/384491#M172175</guid>
      <dc:creator>veerendra_modi</dc:creator>
      <dc:date>2019-03-29T08:24:55Z</dc:date>
    </item>
    <item>
      <title>Re: How do you change a row by checking another row?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-change-a-row-by-checking-another-row/m-p/384492#M172176</link>
      <description>&lt;P&gt;@veerendra_modi &lt;/P&gt;

&lt;P&gt;You can try &lt;CODE&gt;Eventstats&lt;/CODE&gt; to access fields of the previous event using stats functions.&lt;/P&gt;

&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/7.2.4/SearchReference/Eventstats"&gt;https://docs.splunk.com/Documentation/Splunk/7.2.4/SearchReference/Eventstats&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Mar 2019 10:16:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-change-a-row-by-checking-another-row/m-p/384492#M172176</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-03-29T10:16:39Z</dc:date>
    </item>
    <item>
      <title>Re: How do you change a row by checking another row?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-change-a-row-by-checking-another-row/m-p/384493#M172177</link>
      <description>&lt;P&gt;Thanks Kamlesh can you help me with the sample code.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Mar 2019 10:43:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-change-a-row-by-checking-another-row/m-p/384493#M172177</guid>
      <dc:creator>veerendra_modi</dc:creator>
      <dc:date>2019-03-29T10:43:19Z</dc:date>
    </item>
    <item>
      <title>Re: How do you change a row by checking another row?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-change-a-row-by-checking-another-row/m-p/384494#M172178</link>
      <description>&lt;P&gt;sure @veerendra_modi &lt;/P&gt;

&lt;P&gt;Please share your search, sample data and expected output.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Mar 2019 10:51:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-change-a-row-by-checking-another-row/m-p/384494#M172178</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-03-29T10:51:08Z</dc:date>
    </item>
    <item>
      <title>Re: How do you change a row by checking another row?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-change-a-row-by-checking-another-row/m-p/384495#M172179</link>
      <description>&lt;P&gt;Consider that i am getting the above data displayed in the screenshot above.&lt;BR /&gt;
The expected output would be that the third row of sourcetype=S2 will be changed to criticality=P2&lt;/P&gt;

&lt;P&gt;See the attachment Result-1.png&lt;/P&gt;</description>
      <pubDate>Fri, 29 Mar 2019 11:00:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-change-a-row-by-checking-another-row/m-p/384495#M172179</guid>
      <dc:creator>veerendra_modi</dc:creator>
      <dc:date>2019-03-29T11:00:07Z</dc:date>
    </item>
    <item>
      <title>Re: How do you change a row by checking another row?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-change-a-row-by-checking-another-row/m-p/384496#M172180</link>
      <description>&lt;P&gt;Maybe I'm missing something, but wouldn't that be as simple as: &lt;CODE&gt;| eval Criticality=if(Id=query AND sourcetype="S2","P2",Criticality)&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Mar 2019 12:16:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-change-a-row-by-checking-another-row/m-p/384496#M172180</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2019-03-29T12:16:35Z</dc:date>
    </item>
    <item>
      <title>Re: How do you change a row by checking another row?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-change-a-row-by-checking-another-row/m-p/384497#M172181</link>
      <description>&lt;P&gt;Thanks Frank&lt;BR /&gt;
what does it mean by Id=query here&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2019 03:35:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-change-a-row-by-checking-another-row/m-p/384497#M172181</guid>
      <dc:creator>veerendra_modi</dc:creator>
      <dc:date>2019-04-01T03:35:22Z</dc:date>
    </item>
    <item>
      <title>Re: How do you change a row by checking another row?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-change-a-row-by-checking-another-row/m-p/384498#M172182</link>
      <description>&lt;P&gt;It checks if those 2 columns match. That is how I interpreted "if its Id is available in the 4th Column".&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2019 07:28:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-change-a-row-by-checking-another-row/m-p/384498#M172182</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2019-04-01T07:28:13Z</dc:date>
    </item>
    <item>
      <title>Re: How do you change a row by checking another row?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-change-a-row-by-checking-another-row/m-p/384499#M172183</link>
      <description>&lt;P&gt;but id and query are different columns, we need to check if an id is available in query 2 and we have same id with sourcetype=S2 then we need to change the Criticality to P2.&lt;BR /&gt;
Is it clear now pls help&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2019 08:54:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-change-a-row-by-checking-another-row/m-p/384499#M172183</guid>
      <dc:creator>veerendra_modi</dc:creator>
      <dc:date>2019-04-01T08:54:20Z</dc:date>
    </item>
    <item>
      <title>Re: How do you change a row by checking another row?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-change-a-row-by-checking-another-row/m-p/384500#M172184</link>
      <description>&lt;P&gt;Ah, so you meant: "if its Id is available in the 4th &lt;STRONG&gt;Row&lt;/STRONG&gt;" instead of Column? Then ignore my answer, let me think if I can come up with something for that.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2019 09:25:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-change-a-row-by-checking-another-row/m-p/384500#M172184</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2019-04-01T09:25:17Z</dc:date>
    </item>
    <item>
      <title>Re: How do you change a row by checking another row?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-change-a-row-by-checking-another-row/m-p/384501#M172185</link>
      <description>&lt;P&gt;If the query field is indeed a number like this, with the basic data showing as 1 and the row to check against showing as 2, then I think this would work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... your current query...
| eventstats max(query) as max_query by Id
| eval Criticality=if(max_query=2 AND sourcetype="S2","P2",Criticality)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note: this is specific to that sourcetype and criticality values.&lt;/P&gt;

&lt;P&gt;If you need this to work more generically as if it was a lookup, it might be easier to actually store the data from query 2 into a lookup. I think a more generic solution with eventstats could look like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... your current query...
| eval CriticalityNew=if(query=2,Criticality,null())
| eventstats values(CriticalityNew) as CriticalityNew by Id,sourcetype
| eval Criticality = coalesce(CriticalityNew,Criticality)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That first eval to copy Criticality to CriticalityNew can perhaps also be achieved by adjusting your current query, such that for rows from query2 the Criticality field is called CriticalityNew.&lt;/P&gt;

&lt;P&gt;Otherwise, a solution using join might work as well:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...query 1...
| join type=left Id, sourcetype [
search ...query 2...
| mvexpand Id
| rename Criticality as CriticalityNew
| table Id, sourcetype,CriticalityNew
]
| eval Criticality = coalesce(CriticalityNew,Criticality)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Apr 2019 09:43:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-change-a-row-by-checking-another-row/m-p/384501#M172185</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2019-04-01T09:43:11Z</dc:date>
    </item>
  </channel>
</rss>

