<?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 achieve conditional count for multivalue field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-achieve-conditional-count-for-multivalue-field/m-p/646857#M223879</link>
    <description>&lt;P&gt;Hi, I'm kind of new to Splunk and I was wondering if someone could help on this:&lt;/P&gt;
&lt;P&gt;What I'm trying to do is a timechart that counts by month, the number of hosts that had 3 or more lastlogons.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So far this is what I have:&lt;/P&gt;
&lt;P&gt;index="assets" sourcetype="ldap:devices"&lt;BR /&gt;| stats values(lastLogonTimestamp) as "LastLogon" by host&lt;BR /&gt;| eval LastLogon_Count = mvcount(LastLogon)&lt;/P&gt;
&lt;P&gt;host LastLogon LastLogon_Count&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;Host1&lt;/TD&gt;
&lt;TD&gt;2023-06-10T14:05:35.849017Z&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Host2&lt;/TD&gt;
&lt;TD&gt;2023-06-10T16:24:01.290211Z&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Host3&lt;/TD&gt;
&lt;TD&gt;
&lt;DIV class=""&gt;2023-03-12T01:30:39.853238Z&lt;/DIV&gt;
&lt;DIV class=""&gt;2023-03-22T12:01:18.877600Z&lt;/DIV&gt;
&lt;DIV class=""&gt;2023-04-01T14:05:33.812544Z&lt;/DIV&gt;
&lt;DIV class=""&gt;2023-04-11T15:34:16.462356Z&lt;/DIV&gt;
&lt;DIV class=""&gt;2023-04-24T11:50:29.265116Z&lt;/DIV&gt;
&lt;DIV class=""&gt;2023-05-04T12:34:50.229455Z&lt;/DIV&gt;
&lt;DIV class=""&gt;2023-05-14T16:16:22.161436Z&lt;/DIV&gt;
&lt;DIV class=""&gt;2023-05-29T00:57:30.342080Z&lt;/DIV&gt;
&lt;/TD&gt;
&lt;TD&gt;8&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Host4&lt;/TD&gt;
&lt;TD&gt;2023-06-10T16:23:14.783142Z&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Host5&lt;/TD&gt;
&lt;TD&gt;2023-06-10T14:05:51.345719Z&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Host6&lt;/TD&gt;
&lt;TD&gt;
&lt;DIV class=""&gt;2023-05-11T14:52:26.019471Z&lt;/DIV&gt;
&lt;DIV class=""&gt;2023-05-21T21:22:27.404659Z&lt;/DIV&gt;
&lt;DIV class=""&gt;2023-05-31T22:02:28.210643Z&lt;/DIV&gt;
&lt;DIV class=""&gt;2023-06-12T00:59:03.121092Z&lt;/DIV&gt;
&lt;/TD&gt;
&lt;TD&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Host7&lt;/TD&gt;
&lt;TD&gt;
&lt;DIV class=""&gt;2023-05-11T14:46:42.864582Z&lt;/DIV&gt;
&lt;DIV class=""&gt;2023-05-21T18:02:34.820364Z&lt;/DIV&gt;
&lt;DIV class=""&gt;2023-05-31T22:13:17.107118Z&lt;/DIV&gt;
&lt;DIV class=""&gt;2023-06-11T00:32:24.358015Z&lt;/DIV&gt;
&lt;/TD&gt;
&lt;TD&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Host8&lt;/TD&gt;
&lt;TD&gt;2023-06-10T14:05:04.812651Z&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Host9&lt;/TD&gt;
&lt;TD&gt;2023-06-10T14:05:20.315748Z&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Host10&lt;/TD&gt;
&lt;TD&gt;2023-06-10T14:06:37.952136Z&lt;/TD&gt;
&lt;TD&gt;1&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 results I want to count on a timechart the hosts that had 3 or more lastlogon on the LastLogon_Count field.&lt;BR /&gt;So let's say here the count should only be &lt;STRONG&gt;3 (Host3,Host6,Host7)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;I tried doing this, but got no results:&lt;BR /&gt;&lt;BR /&gt;index="assets" sourcetype="ldap:devices"&lt;BR /&gt;| stats values(lastLogonTimestamp) as "LastLogon" by host&lt;BR /&gt;| eval LastLogon_Count = mvcount(LastLogon)&lt;BR /&gt;| timechart span=1mon count(eval(if(LastLogon_Count &amp;gt;= 3, 1,0))) by host&lt;/P&gt;</description>
    <pubDate>Thu, 15 Jun 2023 12:37:58 GMT</pubDate>
    <dc:creator>luis_carlos</dc:creator>
    <dc:date>2023-06-15T12:37:58Z</dc:date>
    <item>
      <title>How to achieve conditional count for multivalue field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-achieve-conditional-count-for-multivalue-field/m-p/646857#M223879</link>
      <description>&lt;P&gt;Hi, I'm kind of new to Splunk and I was wondering if someone could help on this:&lt;/P&gt;
&lt;P&gt;What I'm trying to do is a timechart that counts by month, the number of hosts that had 3 or more lastlogons.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So far this is what I have:&lt;/P&gt;
&lt;P&gt;index="assets" sourcetype="ldap:devices"&lt;BR /&gt;| stats values(lastLogonTimestamp) as "LastLogon" by host&lt;BR /&gt;| eval LastLogon_Count = mvcount(LastLogon)&lt;/P&gt;
&lt;P&gt;host LastLogon LastLogon_Count&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;Host1&lt;/TD&gt;
&lt;TD&gt;2023-06-10T14:05:35.849017Z&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Host2&lt;/TD&gt;
&lt;TD&gt;2023-06-10T16:24:01.290211Z&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Host3&lt;/TD&gt;
&lt;TD&gt;
&lt;DIV class=""&gt;2023-03-12T01:30:39.853238Z&lt;/DIV&gt;
&lt;DIV class=""&gt;2023-03-22T12:01:18.877600Z&lt;/DIV&gt;
&lt;DIV class=""&gt;2023-04-01T14:05:33.812544Z&lt;/DIV&gt;
&lt;DIV class=""&gt;2023-04-11T15:34:16.462356Z&lt;/DIV&gt;
&lt;DIV class=""&gt;2023-04-24T11:50:29.265116Z&lt;/DIV&gt;
&lt;DIV class=""&gt;2023-05-04T12:34:50.229455Z&lt;/DIV&gt;
&lt;DIV class=""&gt;2023-05-14T16:16:22.161436Z&lt;/DIV&gt;
&lt;DIV class=""&gt;2023-05-29T00:57:30.342080Z&lt;/DIV&gt;
&lt;/TD&gt;
&lt;TD&gt;8&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Host4&lt;/TD&gt;
&lt;TD&gt;2023-06-10T16:23:14.783142Z&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Host5&lt;/TD&gt;
&lt;TD&gt;2023-06-10T14:05:51.345719Z&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Host6&lt;/TD&gt;
&lt;TD&gt;
&lt;DIV class=""&gt;2023-05-11T14:52:26.019471Z&lt;/DIV&gt;
&lt;DIV class=""&gt;2023-05-21T21:22:27.404659Z&lt;/DIV&gt;
&lt;DIV class=""&gt;2023-05-31T22:02:28.210643Z&lt;/DIV&gt;
&lt;DIV class=""&gt;2023-06-12T00:59:03.121092Z&lt;/DIV&gt;
&lt;/TD&gt;
&lt;TD&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Host7&lt;/TD&gt;
&lt;TD&gt;
&lt;DIV class=""&gt;2023-05-11T14:46:42.864582Z&lt;/DIV&gt;
&lt;DIV class=""&gt;2023-05-21T18:02:34.820364Z&lt;/DIV&gt;
&lt;DIV class=""&gt;2023-05-31T22:13:17.107118Z&lt;/DIV&gt;
&lt;DIV class=""&gt;2023-06-11T00:32:24.358015Z&lt;/DIV&gt;
&lt;/TD&gt;
&lt;TD&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Host8&lt;/TD&gt;
&lt;TD&gt;2023-06-10T14:05:04.812651Z&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Host9&lt;/TD&gt;
&lt;TD&gt;2023-06-10T14:05:20.315748Z&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Host10&lt;/TD&gt;
&lt;TD&gt;2023-06-10T14:06:37.952136Z&lt;/TD&gt;
&lt;TD&gt;1&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 results I want to count on a timechart the hosts that had 3 or more lastlogon on the LastLogon_Count field.&lt;BR /&gt;So let's say here the count should only be &lt;STRONG&gt;3 (Host3,Host6,Host7)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;I tried doing this, but got no results:&lt;BR /&gt;&lt;BR /&gt;index="assets" sourcetype="ldap:devices"&lt;BR /&gt;| stats values(lastLogonTimestamp) as "LastLogon" by host&lt;BR /&gt;| eval LastLogon_Count = mvcount(LastLogon)&lt;BR /&gt;| timechart span=1mon count(eval(if(LastLogon_Count &amp;gt;= 3, 1,0))) by host&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 12:37:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-achieve-conditional-count-for-multivalue-field/m-p/646857#M223879</guid>
      <dc:creator>luis_carlos</dc:creator>
      <dc:date>2023-06-15T12:37:58Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Count for Multivalue Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-achieve-conditional-count-for-multivalue-field/m-p/646872#M223884</link>
      <description>&lt;P&gt;Try a simpler expression in the timechart command.&lt;/P&gt;&lt;P&gt;Either&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="assets" sourcetype="ldap:devices"
| stats values(lastLogonTimestamp) as "LastLogon" by host
| eval LastLogon_Count = mvcount(LastLogon)
| where LastLogon_Count &amp;gt;= 3
| timechart span=1mon count by host&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;Or&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="assets" sourcetype="ldap:devices"
| stats values(lastLogonTimestamp) as "LastLogon" by host
| eval LastLogon_Count = mvcount(LastLogon)
| eval too_many = if(LastLogon_Count &amp;gt;= 3, 1, 0)
| timechart span=1mon sum(too_many) by host&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 13 Jun 2023 21:03:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-achieve-conditional-count-for-multivalue-field/m-p/646872#M223884</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2023-06-13T21:03:18Z</dc:date>
    </item>
  </channel>
</rss>

