<?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: Using variables in mvfilter with match or how to get  an mvdistinctcount(var) in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Using-variables-in-mvfilter-with-match-or-how-to-get-an/m-p/34354#M7370</link>
    <description>&lt;P&gt;Hi Chris,&lt;/P&gt;

&lt;P&gt;There is also a &lt;A href="http://www.splunk.com/base/Documentation/latest/SearchReference/Stats" rel="nofollow"&gt;stats function&lt;/A&gt;, &lt;CODE&gt;values()&lt;/CODE&gt;, that you could try. It returns the list of all distinct values of the multivalue field. So, your search could include something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats values(mvfield) AS mvfieldvalues | where count(mvfieldvalues) &amp;gt; 1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can read more about &lt;A href="http://www.splunk.com/base/Documentation/latest/SearchReference/CommonStatsFunctions" rel="nofollow"&gt;stats functions&lt;/A&gt; in the search reference manual.&lt;/P&gt;</description>
    <pubDate>Fri, 28 Jan 2011 01:10:59 GMT</pubDate>
    <dc:creator>sophy</dc:creator>
    <dc:date>2011-01-28T01:10:59Z</dc:date>
    <item>
      <title>Using variables in mvfilter with match or how to get  an mvdistinctcount(var)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-variables-in-mvfilter-with-match-or-how-to-get-an/m-p/34353#M7369</link>
      <description>&lt;P&gt;Hi everyone&lt;/P&gt;

&lt;P&gt;We would like to be able to find out if a certain field which occurs several times in a transaction changes its value during that transaction (e.g. the browser language changes during a session)&lt;/P&gt;

&lt;P&gt;We have a rex that grabs all the values into a mv-field. What we would like to do now is a:
mvdistinctcount(mvfield) -&amp;gt; if the result is bigger than 1 we win.&lt;/P&gt;

&lt;P&gt;We thought that doing this would accomplish the same:  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval first_element=mvindex(my_WT_ul,0) 
| eval same_ul = mvfilter(match(my_WT_ul, first_element)) 
| eval lang_change=mvcount(my_WT_ul)-mvcount(same_ul)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The idea here being if all the values are equal to the first value in the field we will get a list that has the same length as the original otherwise we don't&lt;/P&gt;

&lt;P&gt;But the  mvfilter does not like fields in the match function if we supply a static string we are ok.&lt;/P&gt;

&lt;P&gt;This is the error message we get:&lt;/P&gt;

&lt;P&gt;Error in 'eval' command: The arguments to the 'mvfilter' function are invalid.&lt;/P&gt;

&lt;P&gt;Any ideas?&lt;/P&gt;

&lt;P&gt;Cheers Chris&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2011 23:43:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-variables-in-mvfilter-with-match-or-how-to-get-an/m-p/34353#M7369</guid>
      <dc:creator>chris</dc:creator>
      <dc:date>2011-01-27T23:43:24Z</dc:date>
    </item>
    <item>
      <title>Re: Using variables in mvfilter with match or how to get  an mvdistinctcount(var)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-variables-in-mvfilter-with-match-or-how-to-get-an/m-p/34354#M7370</link>
      <description>&lt;P&gt;Hi Chris,&lt;/P&gt;

&lt;P&gt;There is also a &lt;A href="http://www.splunk.com/base/Documentation/latest/SearchReference/Stats" rel="nofollow"&gt;stats function&lt;/A&gt;, &lt;CODE&gt;values()&lt;/CODE&gt;, that you could try. It returns the list of all distinct values of the multivalue field. So, your search could include something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats values(mvfield) AS mvfieldvalues | where count(mvfieldvalues) &amp;gt; 1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can read more about &lt;A href="http://www.splunk.com/base/Documentation/latest/SearchReference/CommonStatsFunctions" rel="nofollow"&gt;stats functions&lt;/A&gt; in the search reference manual.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jan 2011 01:10:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-variables-in-mvfilter-with-match-or-how-to-get-an/m-p/34354#M7370</guid>
      <dc:creator>sophy</dc:creator>
      <dc:date>2011-01-28T01:10:59Z</dc:date>
    </item>
    <item>
      <title>Re: Using variables in mvfilter with match or how to get  an mvdistinctcount(var)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-variables-in-mvfilter-with-match-or-how-to-get-an/m-p/34355#M7371</link>
      <description>&lt;P&gt;Hi sophy, thanks for your solution. What worked for me in the end was this: ... | eventstats values(mvfield) as mvfieldvalues by mvfield | where mvcount(mvfieldvalues) &amp;gt; 1&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jan 2011 16:31:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-variables-in-mvfilter-with-match-or-how-to-get-an/m-p/34355#M7371</guid>
      <dc:creator>chris</dc:creator>
      <dc:date>2011-01-28T16:31:36Z</dc:date>
    </item>
    <item>
      <title>Re: Using variables in mvfilter with match or how to get  an mvdistinctcount(var)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-variables-in-mvfilter-with-match-or-how-to-get-an/m-p/34356#M7372</link>
      <description>&lt;P&gt;even better! (^_^)/&lt;/P&gt;</description>
      <pubDate>Sat, 29 Jan 2011 01:07:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-variables-in-mvfilter-with-match-or-how-to-get-an/m-p/34356#M7372</guid>
      <dc:creator>sophy</dc:creator>
      <dc:date>2011-01-29T01:07:00Z</dc:date>
    </item>
  </channel>
</rss>

