<?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 How to grab a different field in an event, based on other criteria in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-grab-a-different-field-in-an-event-based-on-other/m-p/705774#M238928</link>
    <description>&lt;P&gt;I have a table that looks like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;Day&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;Percent&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;2024-11-01&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;100&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;2024-11-02&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;99.6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;2024-11-03&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;94.2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="25px"&gt;...&lt;/TD&gt;&lt;TD height="25px"&gt;...&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="25px"&gt;2024-12-01&lt;/TD&gt;&lt;TD height="25px"&gt;22.1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="25px"&gt;2024-12-02&lt;/TD&gt;&lt;TD height="25px"&gt;19.0&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From this table I am calculating three fields: REMEDIATION_50, _80, and _100 using the following&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;|eval REMEDIATION_50 = if(PERCENTAGE &amp;lt;= 50, "x", "")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From this eval statement, I am going to have multiple rows where the _50, and _80 rows are marked, and some where both fields are marked.&amp;nbsp; I'm interested in isolating the DAY of the first time each of these milestones are hit.&amp;nbsp; I've yet to craft the right combination of stats, where, and evals that gets me what I want.&lt;/P&gt;&lt;P&gt;In the end, I'd like to get to this of sorts&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="25%"&gt;Start&lt;/TD&gt;&lt;TD width="25%"&gt;50%&lt;/TD&gt;&lt;TD width="25%"&gt;80%&lt;/TD&gt;&lt;TD width="25%"&gt;100%&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%"&gt;2024-11-01&lt;/TD&gt;&lt;TD width="25%"&gt;2024-11-23&lt;/TD&gt;&lt;TD width="25%"&gt;2024-12-02&lt;/TD&gt;&lt;TD width="25%"&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated, thanks!&lt;/P&gt;</description>
    <pubDate>Tue, 03 Dec 2024 02:28:36 GMT</pubDate>
    <dc:creator>DATT</dc:creator>
    <dc:date>2024-12-03T02:28:36Z</dc:date>
    <item>
      <title>How to grab a different field in an event, based on other criteria</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-grab-a-different-field-in-an-event-based-on-other/m-p/705774#M238928</link>
      <description>&lt;P&gt;I have a table that looks like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;Day&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;Percent&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;2024-11-01&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;100&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;2024-11-02&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;99.6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;2024-11-03&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;94.2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="25px"&gt;...&lt;/TD&gt;&lt;TD height="25px"&gt;...&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="25px"&gt;2024-12-01&lt;/TD&gt;&lt;TD height="25px"&gt;22.1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="25px"&gt;2024-12-02&lt;/TD&gt;&lt;TD height="25px"&gt;19.0&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From this table I am calculating three fields: REMEDIATION_50, _80, and _100 using the following&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;|eval REMEDIATION_50 = if(PERCENTAGE &amp;lt;= 50, "x", "")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From this eval statement, I am going to have multiple rows where the _50, and _80 rows are marked, and some where both fields are marked.&amp;nbsp; I'm interested in isolating the DAY of the first time each of these milestones are hit.&amp;nbsp; I've yet to craft the right combination of stats, where, and evals that gets me what I want.&lt;/P&gt;&lt;P&gt;In the end, I'd like to get to this of sorts&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="25%"&gt;Start&lt;/TD&gt;&lt;TD width="25%"&gt;50%&lt;/TD&gt;&lt;TD width="25%"&gt;80%&lt;/TD&gt;&lt;TD width="25%"&gt;100%&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%"&gt;2024-11-01&lt;/TD&gt;&lt;TD width="25%"&gt;2024-11-23&lt;/TD&gt;&lt;TD width="25%"&gt;2024-12-02&lt;/TD&gt;&lt;TD width="25%"&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated, thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 03 Dec 2024 02:28:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-grab-a-different-field-in-an-event-based-on-other/m-p/705774#M238928</guid>
      <dc:creator>DATT</dc:creator>
      <dc:date>2024-12-03T02:28:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to grab a different field in an event, based on other criteria</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-grab-a-different-field-in-an-event-based-on-other/m-p/705777#M238930</link>
      <description>&lt;P&gt;Is this what you're after&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults format=csv data="Day,Percent
2024-11-01,100
2024-11-02,99.6
2024-11-03,94.2
2024-12-01,22.1
2024-12-02,19.0"
| eval _time=strptime(Day, "%F")
| foreach 50 80 100 [ eval REMEDIATION_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = if(Percent &amp;lt;= &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;, 1,null())]
| stats earliest_time(_time) as Start earliest_time(REMEDIATION_*) as r_*
| foreach r_* [ eval &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;%=&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; | fields - &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; ]
| foreach * [ eval "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"=strftime('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;', "%F") ]&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 03 Dec 2024 06:41:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-grab-a-different-field-in-an-event-based-on-other/m-p/705777#M238930</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2024-12-03T06:41:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to grab a different field in an event, based on other criteria</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-grab-a-different-field-in-an-event-based-on-other/m-p/705867#M238960</link>
      <description>&lt;P&gt;This gets me pretty close to what I need.&amp;nbsp; I modified it slightly to get to the data I need:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults format=csv data="Day,Percent
2024-11-01,100
2024-11-02,99.6
2024-11-03,94.2
2024-11-04, 79.9
2024-11-30, 49.9
2024-12-01,22.1
2024-12-02,19.0" 

| eval _time=strptime(Day, "%F") 
| foreach 50 80 100
    [ eval REMAINING = 100 - &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; 
    | eval REMEDIATION_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = if(Percent &amp;lt;= REMAINING, 1, null())] 
   
| stats earliest_time(_time) as Start earliest_time(REMEDIATION_*) as r_*&lt;/LI-CODE&gt;&lt;P&gt;I'll need to figure out a way to get the 100% field to show up after the stats command but I know I can do that in a brute force manner if necessary.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I haven't seen foreach before so thank you for such a concise, relevant example.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Dec 2024 17:55:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-grab-a-different-field-in-an-event-based-on-other/m-p/705867#M238960</guid>
      <dc:creator>DATT</dc:creator>
      <dc:date>2024-12-03T17:55:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to grab a different field in an event, based on other criteria</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-grab-a-different-field-in-an-event-based-on-other/m-p/705889#M238961</link>
      <description>&lt;P&gt;foreach is immensely powerful and leads you to a place where in your SPL you can use good field naming conventions to create concise, if a little more obtuse, logic. Here it's using numbers, but you typically use it with fields and then wildcards then a good naming strategy become important as it allows you to handle unknown field names.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Dec 2024 23:39:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-grab-a-different-field-in-an-event-based-on-other/m-p/705889#M238961</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2024-12-03T23:39:30Z</dc:date>
    </item>
  </channel>
</rss>

