<?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 can I get the last index of my target value for a multi-value field ? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-last-index-of-my-target-value-for-a-multi/m-p/626519#M217757</link>
    <description>&lt;P&gt;That is why you always need to give all critical details about data. &amp;nbsp;Just as you described, we'll split at "PayForIt" before proceeding further.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval chain = mvmap(chain, replace(chain, "PayForIt", "PayForIt:")) ``` add marker for split ```
| eval chain = split(mvjoin(chain, ","), ":") ``` split right after PayForIt ```
| mvexpand chain ``` each PayForIt in its own event ```
| eval chain = split(chain, ",")
| where isnotnull(chain)
| foreach SendMessage CheckMessage
    [ eval abnormal = if(mvfind(chain, "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;") &amp;gt; mvfind(chain, "PayForIt") OR NOT in(chain, "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;") OR abnormal == "yes", "yes", "no") ]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You get something like&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;id&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;chain&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;abnormal&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;SendMessage&lt;/DIV&gt;&lt;DIV class=""&gt;CheckMessage&lt;/DIV&gt;&lt;DIV class=""&gt;PayForIt&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;SendMessage&lt;/DIV&gt;&lt;DIV class=""&gt;CheckMessage&lt;/DIV&gt;&lt;DIV class=""&gt;PayForIt&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;CheckMessage&lt;/DIV&gt;&lt;DIV class=""&gt;SendMessage&lt;/DIV&gt;&lt;DIV class=""&gt;CheckMessage&lt;/DIV&gt;&lt;DIV class=""&gt;PayForIt&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;PayForIt&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;SendMessage&lt;/DIV&gt;&lt;DIV class=""&gt;CheckMessage&lt;/DIV&gt;&lt;DIV class=""&gt;PayForIt&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;SendMessage&lt;/DIV&gt;&lt;DIV class=""&gt;PayForIt&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;CheckMessage&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;SendMessage&lt;/DIV&gt;&lt;DIV class=""&gt;PayForIt&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Emulated data are the following:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;id&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;chain&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;SendMessage&lt;/DIV&gt;&lt;DIV class=""&gt;CheckMessage&lt;/DIV&gt;&lt;DIV class=""&gt;PayForIt&lt;/DIV&gt;&lt;DIV class=""&gt;SendMessage&lt;/DIV&gt;&lt;DIV class=""&gt;CheckMessage&lt;/DIV&gt;&lt;DIV class=""&gt;PayForIt&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;CheckMessage&lt;/DIV&gt;&lt;DIV class=""&gt;SendMessage&lt;/DIV&gt;&lt;DIV class=""&gt;CheckMessage&lt;/DIV&gt;&lt;DIV class=""&gt;PayForIt&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;PayForIt&lt;/DIV&gt;&lt;DIV class=""&gt;SendMessage&lt;/DIV&gt;&lt;DIV class=""&gt;CheckMessage&lt;/DIV&gt;&lt;DIV class=""&gt;PayForIt&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;SendMessage&lt;/DIV&gt;&lt;DIV class=""&gt;PayForIt&lt;/DIV&gt;&lt;DIV class=""&gt;CheckMessage&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;SendMessage&lt;/DIV&gt;&lt;DIV class=""&gt;PayForIt&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;This is used for the emulation:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw ="id	chain
1	SendMessage,CheckMessage,PayForIt,SendMessage,CheckMessage,PayForIt
2	CheckMessage,SendMessage,CheckMessage,PayForIt
3	PayForIt,SendMessage,CheckMessage,PayForIt
4	SendMessage,PayForIt,CheckMessage
5	SendMessage,PayForIt"
| multikv forceheader=1
| eval chain = split(chain, ",")
| table id chain
``` data emulation above ```&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 10 Jan 2023 07:40:24 GMT</pubDate>
    <dc:creator>yuanliu</dc:creator>
    <dc:date>2023-01-10T07:40:24Z</dc:date>
    <item>
      <title>How can I get the last index of my target value for a multi-value field ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-last-index-of-my-target-value-for-a-multi/m-p/625701#M217486</link>
      <description>&lt;P&gt;I want to get the&amp;nbsp;last index of my target value for a multi-value field. For example,&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;id&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;chain&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;1&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;&lt;P&gt;SendMessage&lt;/P&gt;&lt;P&gt;CheckMessage&lt;/P&gt;&lt;P&gt;PayForIt&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;2&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;&lt;P&gt;CheckMessage&lt;/P&gt;&lt;P&gt;SendMessage&lt;/P&gt;&lt;P&gt;CheckMessage&lt;/P&gt;&lt;P&gt;PayForIt&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;PayForIt&lt;/P&gt;&lt;P&gt;SendMessage&lt;/P&gt;&lt;P&gt;CheckMessage&lt;/P&gt;&lt;P&gt;PayForIt&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;SendMessage&lt;/P&gt;&lt;P&gt;PayForIt&lt;/P&gt;&lt;P&gt;CheckMessage&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If "PayForIt" appears, meanwhile&amp;nbsp; "SendMessage" and "CheckMessage" appears before it, this is a&amp;nbsp;normal event. But if&amp;nbsp;"SendMessage" or "CheckMessage" don't appear, or after "PayForIt", it is a&amp;nbsp;abnormal event. It means you must send message and be&amp;nbsp;verified by SMS before you pay for something!&lt;/P&gt;&lt;P&gt;The id 1, 2 and 3 above are normal, 4 is abnormal.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried &lt;STRONG&gt;mvfind&amp;nbsp;&lt;/STRONG&gt;like below, but it will treat 2, 3 as abnormal event!&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;  eval send=mvfind(chain,"SendMessage")
| eval check=mvfind(chain,"CheckMessage")
| eval pay=mvfind(chain,"PayForIt")
| where isnotnull(pay) and isnotnull(check) and isnotnull(send) and pay&amp;gt;check and check&amp;gt;send&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 04 Jan 2023 15:52:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-last-index-of-my-target-value-for-a-multi/m-p/625701#M217486</guid>
      <dc:creator>Jackiifilwhh</dc:creator>
      <dc:date>2023-01-04T15:52:54Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the last index of my target value for a multi-value field ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-last-index-of-my-target-value-for-a-multi/m-p/625775#M217510</link>
      <description>&lt;P&gt;Are you looking for&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Mvexpand" target="_blank" rel="noopener"&gt;mvexpand&lt;/A&gt;&amp;nbsp;instead?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| mvexpand chain
| where chain == "coffee"
| stats latest(index)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 04 Jan 2023 05:24:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-last-index-of-my-target-value-for-a-multi/m-p/625775#M217510</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-01-04T05:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the last index of my target value for a multi-value field ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-last-index-of-my-target-value-for-a-multi/m-p/625842#M217537</link>
      <description>&lt;P&gt;Does something like this help?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| streamstats count as row
| mvexpand chain
| streamstats count by row chain
| stats max(count) as lastindex by row chain&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 04 Jan 2023 15:26:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-last-index-of-my-target-value-for-a-multi/m-p/625842#M217537</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-01-04T15:26:34Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the last index of my target value for a multi-value field ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-last-index-of-my-target-value-for-a-multi/m-p/625856#M217540</link>
      <description>&lt;P&gt;Thank you! I've modified my question, it seems that I can't expand chain to a single value field!&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jan 2023 15:55:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-last-index-of-my-target-value-for-a-multi/m-p/625856#M217540</guid>
      <dc:creator>Jackiifilwhh</dc:creator>
      <dc:date>2023-01-04T15:55:11Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the last index of my target value for a multi-value field ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-last-index-of-my-target-value-for-a-multi/m-p/625857#M217541</link>
      <description>Thank you! I've modified my question, it seems that I can't expand chain to a single value field!</description>
      <pubDate>Wed, 04 Jan 2023 15:55:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-last-index-of-my-target-value-for-a-multi/m-p/625857#M217541</guid>
      <dc:creator>Jackiifilwhh</dc:creator>
      <dc:date>2023-01-04T15:55:40Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the last index of my target value for a multi-value field ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-last-index-of-my-target-value-for-a-multi/m-p/625859#M217542</link>
      <description>&lt;P&gt;Why can't you mvexpand chain?&lt;/P&gt;&lt;P&gt;Also, how is chain created in the first place - can you tag the occurrences of each chain type before creating the multivalue field?&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jan 2023 16:10:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-last-index-of-my-target-value-for-a-multi/m-p/625859#M217542</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-01-04T16:10:30Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the last index of my target value for a multi-value field ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-last-index-of-my-target-value-for-a-multi/m-p/625863#M217544</link>
      <description>&lt;P&gt;Well, let me describe the generation of field "chain".&lt;/P&gt;&lt;P&gt;A user's access to my system is based on a unique session_ id(same name's field in Splunk). And the whole access can be divided into many transactions, named trans_id in Splunk. So I can use the command below to get a user's path of transactions in time order, which named "chain".&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;  stats count by session_id trans_id _time
| eval lux=_time+"|"+trans_id
| stats values(lux) as chain by session_id
| eval chain=mvmap(chain,mvindex(split(chain,"|"),1))&lt;/LI-CODE&gt;&lt;P&gt;Above is the process of generating field "chain". In a word, I want to find the abnormal event, which means that the order is&amp;nbsp;incorrect or the value is incomplete. Just like a customer must be verified by SMS before pay something.&lt;/P&gt;&lt;P&gt;Thanks a lot!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jan 2023 16:33:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-last-index-of-my-target-value-for-a-multi/m-p/625863#M217544</guid>
      <dc:creator>Jackiifilwhh</dc:creator>
      <dc:date>2023-01-04T16:33:53Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the last index of my target value for a multi-value field ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-last-index-of-my-target-value-for-a-multi/m-p/625913#M217562</link>
      <description>&lt;P&gt;This restated question is much clearer about your intentions and logic. &amp;nbsp;What you need is to iterate&amp;nbsp;&lt;SPAN&gt;"SendMessage" over "CheckMessage" using &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Foreach" target="_blank" rel="noopener"&gt;foreach&lt;/A&gt; to compare with the index of "PayForIt". &amp;nbsp;Like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| foreach SendMessage CheckMessage
    [ eval abnormal = if(mvfind(chain, "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;") &amp;gt; mvfind(chain, "PayForIt") OR NOT in(chain, "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;") OR abnormal == "yes", "yes", "no") ]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;followed by a where command.&lt;/P&gt;&lt;P&gt;This is an emulation that you can play with and compare with your real data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw ="id	chain
1	SendMessage,CheckMessage,PayForIt
2	CheckMessage,SendMessage,CheckMessage,PayForIt
3	PayForIt,SendMessage,CheckMessage,PayForIt
4	SendMessage,PayForIt,CheckMessage
5	SendMessage,PayForIt"
| multikv forceheader=1
| eval chain = split(chain, ",")
| table id chain
``` data emulation above ```&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;id&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;chain&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;abnormal&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;SendMessage&lt;/DIV&gt;&lt;DIV class=""&gt;CheckMessage&lt;/DIV&gt;&lt;DIV class=""&gt;PayForIt&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;CheckMessage&lt;/DIV&gt;&lt;DIV class=""&gt;SendMessage&lt;/DIV&gt;&lt;DIV class=""&gt;CheckMessage&lt;/DIV&gt;&lt;DIV class=""&gt;PayForIt&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;PayForIt&lt;/DIV&gt;&lt;DIV class=""&gt;SendMessage&lt;/DIV&gt;&lt;DIV class=""&gt;CheckMessage&lt;/DIV&gt;&lt;DIV class=""&gt;PayForIt&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;SendMessage&lt;/DIV&gt;&lt;DIV class=""&gt;PayForIt&lt;/DIV&gt;&lt;DIV class=""&gt;CheckMessage&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;SendMessage&lt;/DIV&gt;&lt;DIV class=""&gt;PayForIt&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Wed, 04 Jan 2023 22:41:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-last-index-of-my-target-value-for-a-multi/m-p/625913#M217562</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-01-04T22:41:00Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the last index of my target value for a multi-value field ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-last-index-of-my-target-value-for-a-multi/m-p/625982#M217583</link>
      <description>&lt;P&gt;Your generation of chain is essentially deduping _time|trans_id and putting them in time order in a multivalue field.&lt;/P&gt;&lt;P&gt;You could try something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| dedup _time trans_id session_id
| sort 0 _time
| streamstats count as sequence_number global=f by session_id
| eval SendMessageSequence = if(trans_id=="SendMessage", sequence_number, null())
| eval CheckMessageSequence = if(trans_id=="CheckMessage", sequence_number, null())
| eval PayForItSequence = if(trans_id=="PayForIt", sequence_number, null())
| stats max(CheckMessageSequence) as lastCheckMessage max(SendMessageSequence) as lastSendMessage min(PayForItSequence) as firstPayForIt by session_id
| eval good=if(firstPayForIt &amp;gt; lastSendMessage AND firstPayForIt &amp;gt; lastCheckMessage, "OK", "NOK")&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 05 Jan 2023 10:37:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-last-index-of-my-target-value-for-a-multi/m-p/625982#M217583</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-01-05T10:37:10Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the last index of my target value for a multi-value field ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-last-index-of-my-target-value-for-a-multi/m-p/626398#M217725</link>
      <description>&lt;P&gt;Thanks a lot! I've tried this command, it works well! But when a customer pay for something several times, the filed "chain" in Splunk will contain several "PayForIt". It seems that I split "chain" into several parts by "PayForIt" and check the value in every part, which would work! If it is a Java program, I will iterate the multifield or a string to check every part, but how can I make it in Splunk?&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2023 12:17:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-last-index-of-my-target-value-for-a-multi/m-p/626398#M217725</guid>
      <dc:creator>Jackiifilwhh</dc:creator>
      <dc:date>2023-01-09T12:17:07Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the last index of my target value for a multi-value field ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-last-index-of-my-target-value-for-a-multi/m-p/626399#M217726</link>
      <description>&lt;P&gt;Thanks a lot! Actually, a customer could pay for some thing for many times, so the field "chain" in Splunk will consist of several "PayForIt". I need to check the every part of it, which split by "PayForIt". I also need to get the last index of "SendMessage" or "CheckMessage" before every "PayForIt". It seems that "mvfind" won't work properly, because it doesn't get the last but the first index.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2023 12:25:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-last-index-of-my-target-value-for-a-multi/m-p/626399#M217726</guid>
      <dc:creator>Jackiifilwhh</dc:creator>
      <dc:date>2023-01-09T12:25:37Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the last index of my target value for a multi-value field ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-last-index-of-my-target-value-for-a-multi/m-p/626402#M217727</link>
      <description>&lt;P&gt;Assuming you want to check for every PayForIt there is a Send and Check, try something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| dedup _time trans_id session_id
| sort 0 -_time
| streamstats count(eval(trans_id=="PayForIt")) as payments global=f by session_id
| sort 0 session_id _time
| streamstats count as sequence_number global=f by session_id payments
| eval SendMessageSequence = if(trans_id=="SendMessage", sequence_number, null())
| eval CheckMessageSequence = if(trans_id=="CheckMessage", sequence_number, null())
| eval PayForItSequence = if(trans_id=="PayForIt", sequence_number, null())
| stats max(CheckMessageSequence) as lastCheckMessage max(SendMessageSequence) as lastSendMessage min(PayForItSequence) as firstPayForIt by session_id payments
| eval good=if(firstPayForIt &amp;gt; lastSendMessage AND firstPayForIt &amp;gt; lastCheckMessage, "OK", "NOK")&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 09 Jan 2023 13:34:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-last-index-of-my-target-value-for-a-multi/m-p/626402#M217727</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-01-09T13:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the last index of my target value for a multi-value field ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-last-index-of-my-target-value-for-a-multi/m-p/626519#M217757</link>
      <description>&lt;P&gt;That is why you always need to give all critical details about data. &amp;nbsp;Just as you described, we'll split at "PayForIt" before proceeding further.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval chain = mvmap(chain, replace(chain, "PayForIt", "PayForIt:")) ``` add marker for split ```
| eval chain = split(mvjoin(chain, ","), ":") ``` split right after PayForIt ```
| mvexpand chain ``` each PayForIt in its own event ```
| eval chain = split(chain, ",")
| where isnotnull(chain)
| foreach SendMessage CheckMessage
    [ eval abnormal = if(mvfind(chain, "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;") &amp;gt; mvfind(chain, "PayForIt") OR NOT in(chain, "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;") OR abnormal == "yes", "yes", "no") ]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You get something like&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;id&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;chain&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;abnormal&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;SendMessage&lt;/DIV&gt;&lt;DIV class=""&gt;CheckMessage&lt;/DIV&gt;&lt;DIV class=""&gt;PayForIt&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;SendMessage&lt;/DIV&gt;&lt;DIV class=""&gt;CheckMessage&lt;/DIV&gt;&lt;DIV class=""&gt;PayForIt&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;CheckMessage&lt;/DIV&gt;&lt;DIV class=""&gt;SendMessage&lt;/DIV&gt;&lt;DIV class=""&gt;CheckMessage&lt;/DIV&gt;&lt;DIV class=""&gt;PayForIt&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;PayForIt&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;SendMessage&lt;/DIV&gt;&lt;DIV class=""&gt;CheckMessage&lt;/DIV&gt;&lt;DIV class=""&gt;PayForIt&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;SendMessage&lt;/DIV&gt;&lt;DIV class=""&gt;PayForIt&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;CheckMessage&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;SendMessage&lt;/DIV&gt;&lt;DIV class=""&gt;PayForIt&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Emulated data are the following:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;id&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;chain&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;SendMessage&lt;/DIV&gt;&lt;DIV class=""&gt;CheckMessage&lt;/DIV&gt;&lt;DIV class=""&gt;PayForIt&lt;/DIV&gt;&lt;DIV class=""&gt;SendMessage&lt;/DIV&gt;&lt;DIV class=""&gt;CheckMessage&lt;/DIV&gt;&lt;DIV class=""&gt;PayForIt&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;CheckMessage&lt;/DIV&gt;&lt;DIV class=""&gt;SendMessage&lt;/DIV&gt;&lt;DIV class=""&gt;CheckMessage&lt;/DIV&gt;&lt;DIV class=""&gt;PayForIt&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;PayForIt&lt;/DIV&gt;&lt;DIV class=""&gt;SendMessage&lt;/DIV&gt;&lt;DIV class=""&gt;CheckMessage&lt;/DIV&gt;&lt;DIV class=""&gt;PayForIt&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;SendMessage&lt;/DIV&gt;&lt;DIV class=""&gt;PayForIt&lt;/DIV&gt;&lt;DIV class=""&gt;CheckMessage&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;SendMessage&lt;/DIV&gt;&lt;DIV class=""&gt;PayForIt&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;This is used for the emulation:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw ="id	chain
1	SendMessage,CheckMessage,PayForIt,SendMessage,CheckMessage,PayForIt
2	CheckMessage,SendMessage,CheckMessage,PayForIt
3	PayForIt,SendMessage,CheckMessage,PayForIt
4	SendMessage,PayForIt,CheckMessage
5	SendMessage,PayForIt"
| multikv forceheader=1
| eval chain = split(chain, ",")
| table id chain
``` data emulation above ```&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2023 07:40:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-last-index-of-my-target-value-for-a-multi/m-p/626519#M217757</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-01-10T07:40:24Z</dc:date>
    </item>
  </channel>
</rss>

