<?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 add value based on matrix comparison in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-value-based-on-matrix-comparison/m-p/536351#M151648</link>
    <description>&lt;P&gt;I'm still working on it. I'm now in this part :&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=_internal 
| head 1 
| fields _raw 
| eval _raw="Status
A, B, A
A, A, B
B, B, A
B, A, B" 
| multikv forceheader=1 
| eval Status=trim(split(Status,",")) 
| rename COMMENT as "the logic" 
| eval State = Status
| foreach State 
[ eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=case(mvdedup(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;)="A" AND mvcount(mvdedup(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;))=1,"Value_1"
,mvdedup(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;)="B" AND mvcount(mvdedup(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;))=1,"Value_4"
,mvfind(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;,"A")=0,"Value_2"
,mvfind(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;,"B")=0,"Value_3") 
| eval remove_index=0,tail=mvindex(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;,(remove_index+1),mvcount(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;)-1),&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=tail] 
| nomv Status 
| streamstats count as Event 
| table Event Status State&lt;/LI-CODE&gt;&lt;P&gt;The following part is for delete the first value of the multivalue field in order to be able to compare each time the first value and the second.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;eval remove_index=0,tail=mvindex(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;,(remove_index+1),mvcount(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;)-1),&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=tail&lt;/LI-CODE&gt;&lt;P&gt;but this solution do no work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 19 Jan 2021 17:03:54 GMT</pubDate>
    <dc:creator>cros</dc:creator>
    <dc:date>2021-01-19T17:03:54Z</dc:date>
    <item>
      <title>How to add value based on matrix comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-value-based-on-matrix-comparison/m-p/535659#M151402</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;My data is logging of support ticket. i retrieved all the change state of each ticket with the transaction command. This command output a list of status for each ticket id.&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I'm trying to do is to compare each pair of Ticket status in order to create a state for management.&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;P&gt;I have this matrix explaining states for all pair of values :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; B&lt;/P&gt;&lt;P&gt;A&amp;nbsp; Value1&amp;nbsp; &amp;nbsp; Value2&lt;/P&gt;&lt;P&gt;B&amp;nbsp; Value3&amp;nbsp; &amp;nbsp; &amp;nbsp;Value4&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;To accomplish this work, I'm using case statement :&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;state=case(match(mvindex(status, 0), "^A$") AND match(mvindex(status, 1), "^A$"), "Value1",&lt;BR /&gt;match(mvindex(status, 0), "^A$") AND match(mvindex(status, 1), "^B$"), "Value2",&lt;BR /&gt;match(mvindex(status, 0), "^B$") AND match(mvindex(status, 1), "^A$"), "Value3",&lt;BR /&gt;match(mvindex(status, 0), "^B$") AND match(mvindex(status, 1), "^B$"), "Value4")&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;For sure my real matrix is much bigger than this. It's why I'm searching an other way to do it.&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;My expected result is a table like this :&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Event&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Status&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; State&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A, B, A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Value2, Value3&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A, A, B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Value1, Value2&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; B, B, A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Value4, Value3&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; 4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; B, A, B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Value3, Value2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;clement&lt;/P&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jan 2021 14:02:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-value-based-on-matrix-comparison/m-p/535659#M151402</guid>
      <dc:creator>cros</dc:creator>
      <dc:date>2021-01-13T14:02:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to add value based on matrix comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-value-based-on-matrix-comparison/m-p/536093#M151569</link>
      <description>&lt;LI-CODE lang="markup"&gt;index=_internal | head 1 | fields _raw
| eval _raw="Status
A, B, A
A, A, B
B, B, A
B, A, B"
| multikv forceheader=1 
| eval Status=trim(split(Status,","))
| rename COMMENT as "the logic"
| eval State_1=mvindex(Status,0,1), State_2=mvindex(Status,1,2)
| table _raw Status State*
| foreach State_* [ eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=case(mvdedup(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;)="A" AND mvcount(mvdedup(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;))=1,"Value_1"
,mvdedup(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;)="B" AND mvcount(mvdedup(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;))=1,"Value_4"
,mvfind(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;,"A")=0,"Value_2"
,mvfind(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;,"B")=0,"Value_3")]
| eval State = State_1.",".State_2
| nomv Status
| streamstats count as Event
| table Event Status State&lt;/LI-CODE&gt;&lt;P&gt;I don't know for sure, since they didn't write it down properly, but is it like this?&lt;/P&gt;</description>
      <pubDate>Sat, 16 Jan 2021 01:06:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-value-based-on-matrix-comparison/m-p/536093#M151569</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2021-01-16T01:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to add value based on matrix comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-value-based-on-matrix-comparison/m-p/536302#M151632</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/184221"&gt;@to4kawa&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think your solution may be good thank you. My only concern is about the number of status. In my example i gave only 3 status for each event. But in reality, the number of status can be different for each event (1, 2, 5, or even more). How can i do to manage this ?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jan 2021 09:13:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-value-based-on-matrix-comparison/m-p/536302#M151632</guid>
      <dc:creator>cros</dc:creator>
      <dc:date>2021-01-19T09:13:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to add value based on matrix comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-value-based-on-matrix-comparison/m-p/536351#M151648</link>
      <description>&lt;P&gt;I'm still working on it. I'm now in this part :&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=_internal 
| head 1 
| fields _raw 
| eval _raw="Status
A, B, A
A, A, B
B, B, A
B, A, B" 
| multikv forceheader=1 
| eval Status=trim(split(Status,",")) 
| rename COMMENT as "the logic" 
| eval State = Status
| foreach State 
[ eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=case(mvdedup(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;)="A" AND mvcount(mvdedup(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;))=1,"Value_1"
,mvdedup(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;)="B" AND mvcount(mvdedup(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;))=1,"Value_4"
,mvfind(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;,"A")=0,"Value_2"
,mvfind(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;,"B")=0,"Value_3") 
| eval remove_index=0,tail=mvindex(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;,(remove_index+1),mvcount(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;)-1),&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=tail] 
| nomv Status 
| streamstats count as Event 
| table Event Status State&lt;/LI-CODE&gt;&lt;P&gt;The following part is for delete the first value of the multivalue field in order to be able to compare each time the first value and the second.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;eval remove_index=0,tail=mvindex(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;,(remove_index+1),mvcount(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;)-1),&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=tail&lt;/LI-CODE&gt;&lt;P&gt;but this solution do no work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jan 2021 17:03:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-value-based-on-matrix-comparison/m-p/536351#M151648</guid>
      <dc:creator>cros</dc:creator>
      <dc:date>2021-01-19T17:03:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to add value based on matrix comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-value-based-on-matrix-comparison/m-p/536404#M151663</link>
      <description>&lt;LI-CODE lang="markup"&gt;index=_internal 
| head 1 
| fields _raw 
| eval _raw="Status
A, B, A
A, A, B
B, B, A
B, A, B" 
| multikv forceheader=1 
| eval Status=trim(split(Status,",")) 
| rename COMMENT as "the logic" 
| eval State = Status 
| eval State=case(mvdedup(Status)="A" AND mvcount(mvdedup(Status))=1,"Value_1"
        ,mvdedup(Status)="B" AND mvcount(mvdedup(Status))=1,"Value_4"
        ,mvfind(Status,"A")=0,"Value_2"
        ,mvfind(Status,"B")=0,"Value_3")  
| eval remove_index=0,tail=mvindex(Status,(remove_index+1),mvcount(Status)-1) ,Status=tail
| eval Status=mvjoin(Status,",") 
| streamstats count as Event 
| table Event Status State&lt;/LI-CODE&gt;&lt;P&gt;&lt;STRONG&gt;foreach&lt;/STRONG&gt; works for fields, not value.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jan 2021 22:45:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-value-based-on-matrix-comparison/m-p/536404#M151663</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2021-01-19T22:45:57Z</dc:date>
    </item>
  </channel>
</rss>

