<?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: Stats by the existence of certain fields in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-achieve-stats-by-the-existence-of-certain-fields/m-p/642997#M222716</link>
    <description>&lt;P&gt;Can you try the below?Just removed the&amp;nbsp;&lt;SPAN&gt;single quote and added&amp;nbsp;double quotation marks&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;base_query&amp;gt; 
| eval group_name = case(isnotnull(parameters{}.Name), "Name", isnotnull(parameters{}.Holder_Id), "Holder_Id", isnotnull(parameters{}.LicenseNumber), "LicenseNumber") 
| stats count by group_name&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 11 May 2023 09:32:08 GMT</pubDate>
    <dc:creator>TrangCIC81</dc:creator>
    <dc:date>2023-05-11T09:32:08Z</dc:date>
    <item>
      <title>How to achieve stats by the existence of certain fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-achieve-stats-by-the-existence-of-certain-fields/m-p/642989#M222714</link>
      <description>&lt;P&gt;I have three types of data entries.&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;{
&amp;lt;Irrelevant field omitted&amp;gt;
"parameters": [
{
"LicenseNumber": "123456"
}
],
"eventTimestamp": "2023-05-09T15:23:57+0300",
}

{
&amp;lt;Irrelevant field omitted&amp;gt;
"parameters": [
{
"Holder_Id": "654321"
}
],
"eventTimestamp": "2023-05-09T15:23:57+0300",
}

{
&amp;lt;Irrelevant field omitted&amp;gt;
"parameters": [
{
"Name": "John Doe"
}
],
"eventTimestamp": "2023-05-09T15:23:57+0300",
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to get stats how many by the field parameter field type as in Name:69, Holder_Id:42,&amp;nbsp;LicenseNumber:76.&lt;/P&gt;
&lt;P&gt;I thought I'd use eval to create a field by the existence of each parameters, but that doesn't work.&lt;/P&gt;
&lt;P&gt;&amp;lt;base_query&amp;gt; | eval group_name = case(isnotnull('parameters{}.Name'), Name, isnotnull('parameters{}.HolderId'), HolderId, isnotnull('parameters{}.LicenseNumber'), LicenseNumber) | stats count by group_name&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2023 11:31:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-achieve-stats-by-the-existence-of-certain-fields/m-p/642989#M222714</guid>
      <dc:creator>Arishtat</dc:creator>
      <dc:date>2023-05-11T11:31:14Z</dc:date>
    </item>
    <item>
      <title>Re: Stats by the existence of certain fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-achieve-stats-by-the-existence-of-certain-fields/m-p/642993#M222715</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/256638"&gt;@Arishtat&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;simplify field names befor an eval command:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rename 'parameters{}.Name' AS Name 'parameters{}.HolderId' AS HolderId 'parameters{}.LicenseNumber' AS LicenseNumber
| eval group_name = case(isnotnull(Name), Name, isnotnull(HolderId), HolderId, isnotnull(LicenseNumber), LicenseNumber) 
| stats count by group_name&lt;/LI-CODE&gt;&lt;P&gt;But anyway, if you only want a count of occurrences of each group_name, you could simply use&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats count by group_name&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2023 09:24:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-achieve-stats-by-the-existence-of-certain-fields/m-p/642993#M222715</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-05-11T09:24:29Z</dc:date>
    </item>
    <item>
      <title>Re: Stats by the existence of certain fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-achieve-stats-by-the-existence-of-certain-fields/m-p/642997#M222716</link>
      <description>&lt;P&gt;Can you try the below?Just removed the&amp;nbsp;&lt;SPAN&gt;single quote and added&amp;nbsp;double quotation marks&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;base_query&amp;gt; 
| eval group_name = case(isnotnull(parameters{}.Name), "Name", isnotnull(parameters{}.Holder_Id), "Holder_Id", isnotnull(parameters{}.LicenseNumber), "LicenseNumber") 
| stats count by group_name&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2023 09:32:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-achieve-stats-by-the-existence-of-certain-fields/m-p/642997#M222716</guid>
      <dc:creator>TrangCIC81</dc:creator>
      <dc:date>2023-05-11T09:32:08Z</dc:date>
    </item>
    <item>
      <title>Re: Stats by the existence of certain fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-achieve-stats-by-the-existence-of-certain-fields/m-p/643004#M222720</link>
      <description>&lt;P&gt;Weird, I'm sure I tried adding double quotes at some point to the eval fields. However, the isnotnull parameter has to be in single quote.&lt;/P&gt;&lt;P&gt;So the correct answer is,&lt;/P&gt;&lt;P&gt;| eval group_name = case(isnotnull('parameters{}.Name'), "Name", isnotnull('parameters{}.HolderId'), "HolderId", isnotnull('parameters{}.LicenseNumber'), "LicenseNumber") | stats count by group_name&lt;/P&gt;&lt;P&gt;Thanks for you help.&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2023 10:06:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-achieve-stats-by-the-existence-of-certain-fields/m-p/643004#M222720</guid>
      <dc:creator>Arishtat</dc:creator>
      <dc:date>2023-05-11T10:06:20Z</dc:date>
    </item>
  </channel>
</rss>

