<?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 I get mvcount to display 0 when no field exists? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-mvcount-to-display-0-when-no-field-exists/m-p/90401#M182273</link>
    <description>&lt;P&gt;Perfect! Thanks for your help!&lt;/P&gt;</description>
    <pubDate>Tue, 16 Oct 2012 08:19:07 GMT</pubDate>
    <dc:creator>DamianS</dc:creator>
    <dc:date>2012-10-16T08:19:07Z</dc:date>
    <item>
      <title>How do I get mvcount to display 0 when no field exists?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-mvcount-to-display-0-when-no-field-exists/m-p/90399#M182271</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;

&lt;P&gt;I have a search that looks something like this:&lt;/P&gt;

&lt;P&gt;foo | extract pairdelim="|;]}" kvdelim="=:" mv_add=true | eval legs=mvcount(Leg)+1 | stats count by id, legs&lt;/P&gt;

&lt;P&gt;The multi value field "Leg" has one of the 3 possible values "", "2", "2 3". I expected mvcount to work like count and when there are no values to display 0.  Is there a way to display what I would I expect?  Explicitly the mapping I wanted to do was from the multi value field "Leg": No Value -&amp;gt; 1, "2" -&amp;gt; 2, "2 3" -&amp;gt; 3&lt;/P&gt;

&lt;P&gt;Any idea?&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2012 15:31:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-mvcount-to-display-0-when-no-field-exists/m-p/90399#M182271</guid>
      <dc:creator>DamianS</dc:creator>
      <dc:date>2012-10-15T15:31:39Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get mvcount to display 0 when no field exists?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-mvcount-to-display-0-when-no-field-exists/m-p/90400#M182272</link>
      <description>&lt;P&gt;The documentation says mvcount returns the number of values of the field if it's multivalued, 1 if it's singlevalued, and NULL otherwise.  Given the mapping you describe, I think you want to do something like this:&lt;/P&gt;

&lt;P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;BR /&gt;
...  | eval legs=if(isnull(Leg),1,mvcount(Leg)+1)&lt;BR /&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2012 17:07:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-mvcount-to-display-0-when-no-field-exists/m-p/90400#M182272</guid>
      <dc:creator>cphair</dc:creator>
      <dc:date>2012-10-15T17:07:31Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get mvcount to display 0 when no field exists?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-mvcount-to-display-0-when-no-field-exists/m-p/90401#M182273</link>
      <description>&lt;P&gt;Perfect! Thanks for your help!&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2012 08:19:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-mvcount-to-display-0-when-no-field-exists/m-p/90401#M182273</guid>
      <dc:creator>DamianS</dc:creator>
      <dc:date>2012-10-16T08:19:07Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get mvcount to display 0 when no field exists?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-mvcount-to-display-0-when-no-field-exists/m-p/90402#M182274</link>
      <description>&lt;P&gt;You're welcome, @DamianS.  Would you mind clicking the checkmark next to my answer to accept it?  Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2012 14:14:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-mvcount-to-display-0-when-no-field-exists/m-p/90402#M182274</guid>
      <dc:creator>cphair</dc:creator>
      <dc:date>2012-10-16T14:14:12Z</dc:date>
    </item>
  </channel>
</rss>

