<?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: Splunk stats count group by multiple fields in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673374#M230569</link>
    <description>&lt;P&gt;Hello &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/214410"&gt;@isoutamo&lt;/a&gt;&amp;nbsp;- thanks for your kind response. I am reframing my problem statement here:&lt;BR /&gt;&lt;BR /&gt;Refer below Sample events from the logs:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;240108 07:12:07  17709   testget1: ===&amp;gt; TRN@instance2.RQ1:  0000002400840162931785-AHGM0000bA [Priority=Low,ScanPriority=0, Rule: Default Rule].
240108 07:12:07  17709   testget1: &amp;lt;--- TRN:  0000002400840162929525-AHGM00015A - S from [RCV.FROM.TEST.SEP2.Q2@QM.ABCD101].&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;I am having issues while fetching data from 2 stats (&lt;EM&gt;TestMQ and Priority_Level&lt;/EM&gt;) count fields together.&lt;/P&gt;&lt;P&gt;Below is the query:&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;index=test_index=*instance*/*testget*
| rex "\:  (?&amp;lt;testgettrn&amp;gt;.*) \- S from"  
| rex "RCV\.FROM\.(?&amp;lt;TestMQ&amp;gt;.*)\@"
| eval Priority_Level=case(Priority="Low", "Low", Priority="Medium", "Medium", Priority="High", "High")
| stats count as TotalCount, count(eval(Priority_Level="Low")) as Low, count(eval(Priority_Level="Medium")) as Medium, count(eval(Priority_Level="High")) as High by TestMQ
| fillnull value=0&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This gives me result like example below:&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;TestMQ    | TotalCount | Low | Medium | High
MQNam1    | 120        | 0   | 0      | 0
MQNam2    | 152        | 0   | 0      | 0
..&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;The problem is that I am getting "0" value for Low, Medium &amp;amp; High columns - which is not correct. I want to combine both the stats and show the group by results of both the fields.&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;If I run the same query with separate stats - it gives individual data correctly.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Case 1:&amp;nbsp;stats count as TotalCount by TestMQ&lt;/STRONG&gt;&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;index=test_index=*instance*/*testget*
| rex "\:  (?&amp;lt;testgettrn&amp;gt;.*) \- S from"  
| rex "RCV\.FROM\.(?&amp;lt;TestMQ&amp;gt;.*)\@"
| eval Priority_Level=case(Priority="Low", "Low", Priority="Medium", "Medium", Priority="High", "High")
| stats count as TotalCount by TestMQ

Example Output:
TestMQ  | TotalCount
MQName  | 201&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;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Case 2:&amp;nbsp;stats count as PriorityCount by Priority_Level&lt;/STRONG&gt;&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;index=test_index=*instance*/*testget*
| rex "\:  (?&amp;lt;testgettrn&amp;gt;.*) \- S from"  
| rex "RCV\.FROM\.(?&amp;lt;TestMQ&amp;gt;.*)\@"
| eval Priority_Level=case(Priority="Low", "Low", Priority="Medium", "Medium", Priority="High", "High")
| stats count as PriorityCount by Priority_Level

Example Output: 
Priority_Level | PriorityCount 
High           |  20
Medium         |  53
Low            |  78&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Please help and suggest.&lt;/P&gt;</description>
    <pubDate>Tue, 09 Jan 2024 09:39:54 GMT</pubDate>
    <dc:creator>shashankk</dc:creator>
    <dc:date>2024-01-09T09:39:54Z</dc:date>
    <item>
      <title>Splunk stats count group by multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673344#M230559</link>
      <description>&lt;P&gt;Hi Splunk Team&lt;BR /&gt;&lt;BR /&gt;I am having issues while fetching data from 2 stats count fields together.&lt;/P&gt;&lt;P&gt;Below is the query:&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;index=test_index&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;| rex "\.(?&amp;lt;TestMQ&amp;gt;.*)\@"&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;| eval Priority_Level=case(Priority="Low", "Low", Priority="Medium", "Medium", Priority="High", "High")&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;| stats count as TotalCount, count(eval(Priority_Level="Low")) as Low, count(eval(Priority_Level="Medium")) as Medium, count(eval(Priority_Level="High")) as High by TestMQ&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;This gives me result like example below:&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;TestMQ&amp;nbsp; &amp;nbsp; | TotalCount | Low | Medium | High&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;MQNam1 | 120&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 0&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;MQNam2 | 152&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 0&lt;/EM&gt;&lt;BR /&gt;..&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;The problem is that I am getting "0" value for Low, Medium &amp;amp; High columns - which is not correct. I want to combine both the stats and show the group by results of both the fields.&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;If I run the same query with separate stats - it gives individual data correctly.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Case 1:&amp;nbsp;stats count as TotalCount by TestMQ&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;index=test_index&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;| rex "\.(?&amp;lt;TestMQ&amp;gt;.*)\@"&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;| eval Priority_Level=case(Priority="Low", "Low", Priority="Medium", "Medium", Priority="High", "High")&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;| stats count as TotalCount by TestMQ&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;Example Output: &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;TestMQ&amp;nbsp; &amp;nbsp; &amp;nbsp;| TotalCount&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;MQName&amp;nbsp; | 201&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Case 2:&amp;nbsp;stats count as PriorityCount by Priority_Level&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;index=test_index&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;| rex "\.(?&amp;lt;TestMQ&amp;gt;.*)\@"&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;| eval Priority_Level=case(Priority="Low", "Low", Priority="Medium", "Medium", Priority="High", "High")&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;| stats count as PriorityCount by Priority_Level&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;Example Output:&amp;nbsp;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Priority_Level | PriorityCount&amp;nbsp;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;High&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&amp;nbsp; 20&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Medium&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; 53&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Low&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; 78&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;Please help and suggest.&lt;BR /&gt;&lt;BR /&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;- kindly assist.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2024 12:11:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673344#M230559</guid>
      <dc:creator>shashankk</dc:creator>
      <dc:date>2024-01-05T12:11:48Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk stats count group by multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673345#M230560</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/258022"&gt;@shashankk&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;try to simplify your search because the eval isn't mandatory:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=test_index
| rex "\.(?&amp;lt;TestMQ&amp;gt;.*)\@"
| stats 
   count AS TotalCount
   count(eval(Priority="Low")) AS Low
   count(eval(Priority="Medium")) AS Medium
   count(eval(Priority="High")) AS High
   BY TestMQ&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2024 12:22:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673345#M230560</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2024-01-05T12:22:55Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk stats count group by multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673358#M230562</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Thank you for your kind response. I tried the suggested approach but the result is same.&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This gives me result like example below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;TestMQ&amp;nbsp; &amp;nbsp; | TotalCount | Low | Medium | High&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;MQNam1 | 120&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 0&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;MQNam2 | 152&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 0&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;The problem is that I am getting "0" value for Low, Medium &amp;amp; High columns - which is not correct. I want to combine both the stats and show the group by results of both the fields.&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;Please suggest.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2024 13:54:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673358#M230562</guid>
      <dc:creator>shashankk</dc:creator>
      <dc:date>2024-01-05T13:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk stats count group by multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673364#M230565</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;how about something like&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=test_index
| rex "\.(?&amp;lt;TestMQ&amp;gt;.*)\@"
| chart count by TestMQ Priority&lt;/LI-CODE&gt;&lt;P&gt;r. Ismo&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS. Please use &amp;lt;/&amp;gt; option when you are writing some SPL etc. That way it's formatted correctly and we can be sure that what we are seeing is what you have written.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2024 14:28:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673364#M230565</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2024-01-05T14:28:33Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk stats count group by multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673368#M230566</link>
      <description>&lt;P&gt;It is interesting because the mechanics itself works.&lt;/P&gt;&lt;P&gt;You can verify it by replacing count(eval()) by creating a temporary field.&lt;/P&gt;&lt;PRE&gt;| stats count(eval(condition))&lt;/PRE&gt;&lt;P&gt;is equivalent to&lt;/P&gt;&lt;PRE&gt;| eval tempfield=if(condition,something,null())&lt;BR /&gt;| stats count(tempfield)&lt;/PRE&gt;&lt;P&gt;So you can rework your search to contain explicit helper fields instead of eval-ed counts and see if they are counted properly and if they are evaluated properly.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2024 14:41:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673368#M230566</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-01-05T14:41:06Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk stats count group by multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673372#M230568</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/214410"&gt;@isoutamo&lt;/a&gt;&amp;nbsp;Thanks for your kind response. I tried with the suggested approach. But it doesn't give the expected result.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=Test
| rex "(?&amp;lt;TestMQ&amp;gt;.*)\@" 
| eval Priority_Level=case(Priority="Low", "Low", Priority="Medium", "Medium", Priority="High", "High")
| chart count BY TestMQ, Priority_Level
| fillnull value=0&lt;/LI-CODE&gt;&lt;P&gt;Getting output as:&lt;BR /&gt;TestMQ | count&lt;BR /&gt;&lt;BR /&gt;Expected output:&lt;BR /&gt;TestMQ | TotalCount | Low | Medium | High&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2024 15:09:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673372#M230568</guid>
      <dc:creator>shashankk</dc:creator>
      <dc:date>2024-01-05T15:09:04Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk stats count group by multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673374#M230569</link>
      <description>&lt;P&gt;Hello &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/214410"&gt;@isoutamo&lt;/a&gt;&amp;nbsp;- thanks for your kind response. I am reframing my problem statement here:&lt;BR /&gt;&lt;BR /&gt;Refer below Sample events from the logs:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;240108 07:12:07  17709   testget1: ===&amp;gt; TRN@instance2.RQ1:  0000002400840162931785-AHGM0000bA [Priority=Low,ScanPriority=0, Rule: Default Rule].
240108 07:12:07  17709   testget1: &amp;lt;--- TRN:  0000002400840162929525-AHGM00015A - S from [RCV.FROM.TEST.SEP2.Q2@QM.ABCD101].&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;I am having issues while fetching data from 2 stats (&lt;EM&gt;TestMQ and Priority_Level&lt;/EM&gt;) count fields together.&lt;/P&gt;&lt;P&gt;Below is the query:&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;index=test_index=*instance*/*testget*
| rex "\:  (?&amp;lt;testgettrn&amp;gt;.*) \- S from"  
| rex "RCV\.FROM\.(?&amp;lt;TestMQ&amp;gt;.*)\@"
| eval Priority_Level=case(Priority="Low", "Low", Priority="Medium", "Medium", Priority="High", "High")
| stats count as TotalCount, count(eval(Priority_Level="Low")) as Low, count(eval(Priority_Level="Medium")) as Medium, count(eval(Priority_Level="High")) as High by TestMQ
| fillnull value=0&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This gives me result like example below:&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;TestMQ    | TotalCount | Low | Medium | High
MQNam1    | 120        | 0   | 0      | 0
MQNam2    | 152        | 0   | 0      | 0
..&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;The problem is that I am getting "0" value for Low, Medium &amp;amp; High columns - which is not correct. I want to combine both the stats and show the group by results of both the fields.&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;If I run the same query with separate stats - it gives individual data correctly.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Case 1:&amp;nbsp;stats count as TotalCount by TestMQ&lt;/STRONG&gt;&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;index=test_index=*instance*/*testget*
| rex "\:  (?&amp;lt;testgettrn&amp;gt;.*) \- S from"  
| rex "RCV\.FROM\.(?&amp;lt;TestMQ&amp;gt;.*)\@"
| eval Priority_Level=case(Priority="Low", "Low", Priority="Medium", "Medium", Priority="High", "High")
| stats count as TotalCount by TestMQ

Example Output:
TestMQ  | TotalCount
MQName  | 201&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;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Case 2:&amp;nbsp;stats count as PriorityCount by Priority_Level&lt;/STRONG&gt;&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;index=test_index=*instance*/*testget*
| rex "\:  (?&amp;lt;testgettrn&amp;gt;.*) \- S from"  
| rex "RCV\.FROM\.(?&amp;lt;TestMQ&amp;gt;.*)\@"
| eval Priority_Level=case(Priority="Low", "Low", Priority="Medium", "Medium", Priority="High", "High")
| stats count as PriorityCount by Priority_Level

Example Output: 
Priority_Level | PriorityCount 
High           |  20
Medium         |  53
Low            |  78&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Please help and suggest.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2024 09:39:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673374#M230569</guid>
      <dc:creator>shashankk</dc:creator>
      <dc:date>2024-01-09T09:39:54Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk stats count group by multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673379#M230570</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/258022"&gt;@shashankk&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;could you share a sample of your full events for Low, Medium and High Priority?&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2024 16:07:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673379#M230570</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2024-01-05T16:07:43Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk stats count group by multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673393#M230579</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Refer below requested sample query and event details:&lt;BR /&gt;&lt;BR /&gt;Kindly suggest.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=test_index=*instance*/*testget*
| rex "\:  (?&amp;lt;testgettrn&amp;gt;.*) \- S from"  
| rex "RCV\.FROM\.(?&amp;lt;TestMQ&amp;gt;.*)\@"
| eval Priority_Level=case(Priority="Low", "Low", Priority="Medium", "Medium", Priority="High", "High")
| stats count as TotalCount, count(eval(Priority_Level="Low")) as Low, count(eval(Priority_Level="Medium")) as Medium, count(eval(Priority_Level="High")) as High by TestMQ
| fillnull value=0&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;Sample Events:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;240105 18:06:03  19287   testget1: ===&amp;gt; TRN@instance.RQ1:  0000002400509150632034-AERG00001A [Priority=Low,ScanPriority=0, Rule: Default Rule].
host = testserver2.com source = /test/test.logsourcetype = testscan

240105 18:06:03  19287   testget1: ===&amp;gt; TRN@instance.RQ1:  0000002400540101635213-AERG00000A [Priority=Low,ScanPriority=0, Rule: Default Rule].
host = testserver2.com source = /test/test.log sourcetype = testscan

240105 18:06:03  19287   testget1: &amp;lt;--- TRN:  0000002481540150632034-AERG00001A - S from [RCV.FROM.TEST.SEP.Q1@QM.ABC123].
host = testserver2.com source = /test/test.log sourcetype = testscan

240105 18:06:03  19287   testget1: &amp;lt;--- TRN:  0000002400547150635213-AERG00000A - S from [RCV.FROM.TEST.SEP.Q1@QM.ABC123].
host = testserver2.com source = /test/test.log sourcetype = testscan

240105 18:02:29  72965   testget1: ===&amp;gt; TRN@instance.RQ1:  0000002400540902427245-AERC000f8A [Priority=Medium,ScanPriority=2, Rule: Default Rule].
host = testserver1.com source = /test/test.log sourcetype = testscan

240105 18:02:29  72965   testget1: ===&amp;gt; TRN@instance.RQ1:  0000001800540152427236-AERC000f7A [Priority=Medium,ScanPriority=2, Rule: Default Rule].
host = testserver1.com source = /test/test.log sourcetype = testscan

240105 18:02:29  72965   testget1: ===&amp;gt; TRN@instance.RQ1:  0000002400540109427216-AERC000f6A [Priority=High,ScanPriority=1, Rule: Default Rule].
host = testserver1.com source = /test/test.log sourcetype = testscan&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2024 17:54:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673393#M230579</guid>
      <dc:creator>shashankk</dc:creator>
      <dc:date>2024-01-05T17:54:35Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk stats count group by multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673399#M230581</link>
      <description>&lt;P&gt;TestMQ doesn't appear in the same events as priority which is why the stats are coming out as zero&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2024 18:18:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673399#M230581</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-01-05T18:18:21Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk stats count group by multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673401#M230582</link>
      <description>&lt;P&gt;OK. In your example data only small subset of events has the RCV.FROM string which you use to anchor for the TestMQ field.&lt;/P&gt;&lt;P&gt;That means that most of the events doesn't have the field.&lt;/P&gt;&lt;P&gt;So if you do stats by that field, you won't get results where there is no value in this field.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2024 18:27:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673401#M230582</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-01-05T18:27:23Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk stats count group by multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673421#M230595</link>
      <description>&lt;P&gt;Is there a common field across the two types of events to correlate them together?&amp;nbsp;&lt;BR /&gt;Since the field TestMQ and Priority are contained in separate events then just doing a simple stats using TestMQ as a by-field will not work.&lt;BR /&gt;&lt;BR /&gt;But if there is some way to stitch the two event type together first, then you could make it work.&lt;BR /&gt;&lt;BR /&gt;I am not familiar enough with the data and the sample size is too small to figure out what that correlation field may be (if it exists at all) but I did put this together as a proof of concept.&lt;BR /&gt;&lt;BR /&gt;Example:&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;base_search&amp;gt;
    | rex "(?:\={3}\&amp;gt;|\&amp;lt;\-{3})\s+TRN[^\:]*\:\s+(?&amp;lt;trn&amp;gt;[^\s]+)"
    | rex "RCV\.FROM\.(?&amp;lt;TestMQ&amp;gt;.*)\@"
    ``` using this rex as a demonstration of an example of correlation field to link events together ```
    | rex "\d+\s+\d{2}(?:\:\d{2}){2}\s+\d+\s+(?&amp;lt;corr_field&amp;gt;[^\:]+)"
    | bucket span=30m _time
    ``` attribute extracted TestMQ field values to events with the same correlation field and close proximity in time ```
    | eventstats
        values(TestMQ) as TestMQ
            by _time, corr_field
    ``` we can now filter down to events with Priority field available now that they have a TestMQ value contribution ```
    | where isnotnull(Priority)
    | chart 
        count as count
            over TestMQ
            by Priority
    | addtotals fieldname="TotalCount"
    | fields + TestMQ, Low, Medium, High, TotalCount&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;Results would look something like this (but probably with more rows with live data)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dtburrows3_0-1704490832494.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28781iCE42A2137D5D7B31/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dtburrows3_0-1704490832494.png" alt="dtburrows3_0-1704490832494.png" /&gt;&lt;/span&gt;&lt;BR /&gt;I would have selected "host" as the correlation field for the example but with the 5 sample events, "testserver1.com" didn't appear to have any TestMQ attribution. So I just extracted "testget1" since that was a common value in the logs. I'm not stating this is the correct correlation field by any-means, just for demonstration purposes only.&lt;BR /&gt;&lt;BR /&gt;Edit:&lt;BR /&gt;And I think you could probably do something similar without using an eventstats command provided a corr_field exists with a 1-to-1 mapping with TestMQ value.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;base_search&amp;gt;
    | rex "(?:\={3}\&amp;gt;|\&amp;lt;\-{3})\s+TRN[^\:]*\:\s+(?&amp;lt;trn&amp;gt;[^\s]+)"
    | rex "RCV\.FROM\.(?&amp;lt;TestMQ&amp;gt;.*)\@"
    | rex "(?:\={3}\&amp;gt;|\&amp;lt;\-{3})\s+TRN[^\:]*\:\s+(?&amp;lt;trn&amp;gt;[^\s]+)"
    | rex "RCV\.FROM\.(?&amp;lt;TestMQ&amp;gt;.*)\@"
    ``` using this rex as a demonstration of an example of correlation field to link events together ```
    | rex "\d+\s+\d{2}(?:\:\d{2}){2}\s+\d+\s+(?&amp;lt;corr_field&amp;gt;[^\:]+)"
    | stats
        count(eval(Priority=="Low")) as Low,
        count(eval(Priority=="Medium")) as Medium,
        count(eval(Priority=="High")) as High,
        values(TestMQ) as TestMQ
            by corr_field
    | fields + TestMQ, Low, Medium, High
    | addtotals fieldname="TotalCount"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2024 22:04:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673421#M230595</guid>
      <dc:creator>dtburrows3</dc:creator>
      <dc:date>2024-01-05T22:04:58Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk stats count group by multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673432#M230603</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/258022"&gt;@shashankk&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;as&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;said, you have the Priority and TestMQ fields in different events, so you canot correlate them.&lt;/P&gt;&lt;P&gt;You have to find a field common to all the events.&lt;/P&gt;&lt;P&gt;So If e.g. Q1 (that's the final part of&amp;nbsp;&lt;SPAN&gt;TestMQ and it's also present in the other events) can be used as key you could run something like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults | eval _raw="240105 18:06:03  19287   testget1: ===&amp;gt; TRN@instance.RQ1:  0000002400509150632034-AERG00001A [Priority=Low,ScanPriority=0, Rule: Default Rule]."
| append [ | makeresults | eval _raw="240105 18:06:03  19287   testget1: ===&amp;gt; TRN@instance.RQ1:  0000002400540101635213-AERG00000A [Priority=Low,ScanPriority=0, Rule: Default Rule]." ]
| append [ | makeresults | eval _raw="240105 18:06:03  19287   testget1: &amp;lt;--- TRN:  0000002481540150632034-AERG00001A - S from [RCV.FROM.TEST.SEP.Q1@QM.ABC123]." ]
| append [ | makeresults | eval _raw="240105 18:06:03  19287   testget1: &amp;lt;--- TRN:  0000002400547150635213-AERG00000A - S from [RCV.FROM.TEST.SEP.Q1@QM.ABC123]. "]
| append [ | makeresults | eval _raw="240105 18:02:29  72965   testget1: ===&amp;gt; TRN@instance.RQ1:  0000002400540902427245-AERC000f8A [Priority=Medium,ScanPriority=2, Rule: Default Rule]." ]
| append [ | makeresults | eval _raw="240105 18:02:29  72965   testget1: ===&amp;gt; TRN@instance.RQ1:  0000001800540152427236-AERC000f7A [Priority=Medium,ScanPriority=2, Rule: Default Rule]."]
| append [ | makeresults | eval _raw="240105 18:02:29  72965   testget1: ===&amp;gt; TRN@instance.RQ1:  0000002400540109427216-AERC000f6A [Priority=High,ScanPriority=1, Rule: Default Rule]." ]
| rex "\:  (?&amp;lt;testgettrn&amp;gt;.*) \- S from"  
| rex "RCV\.FROM\.(?&amp;lt;TestMQ&amp;gt;.*)\@"
| rex field=TestMQ "\w+\.\w+\.(?&amp;lt;key&amp;gt;\w+)"
| rex "TRN\@instance\.R(?&amp;lt;key&amp;gt;[^:]++):"
| rex "Priority\=(?&amp;lt;Priority&amp;gt;\w+)"
| stats values(TestMQ) AS TestMQ count(eval(Priority="Low")) as Low, count(eval(Priority="Medium")) as Medium, count(eval(Priority="High")) as High BY key
| fillnull value=0
| addtotals&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Sat, 06 Jan 2024 09:32:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673432#M230603</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2024-01-06T09:32:13Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk stats count group by multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673498#M230621</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;In this case I can see the TransactionID is the common field between both the events (TestMQ and Priority) - but I am unable to find how to use the same in the query.&lt;/P&gt;&lt;P&gt;Can you please help and suggest on it? Or can we do a JOIN based transaction id's (for both the event types - TestMQ &amp;amp; Priority)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex field=_raw "(?&amp;lt;TransactionID&amp;gt;\d+-\w+)"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jan 2024 07:57:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673498#M230621</guid>
      <dc:creator>shashankk</dc:creator>
      <dc:date>2024-01-08T07:57:47Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk stats count group by multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673504#M230622</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/258022"&gt;@shashankk&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;don't use join because searches are very sow!&lt;/P&gt;&lt;P&gt;using my search you extract the common key that permits to correlate events containing the TestMQ and Priority fields, and thesearch displays the result as you like.&lt;/P&gt;&lt;P&gt;then you could also don't diplay the key used for the correlation having exactly the result you want:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults | eval _raw="240105 18:06:03  19287   testget1: ===&amp;gt; TRN@instance.RQ1:  0000002400509150632034-AERG00001A [Priority=Low,ScanPriority=0, Rule: Default Rule]."
| append [ | makeresults | eval _raw="240105 18:06:03  19287   testget1: ===&amp;gt; TRN@instance.RQ1:  0000002400540101635213-AERG00000A [Priority=Low,ScanPriority=0, Rule: Default Rule]." ]
| append [ | makeresults | eval _raw="240105 18:06:03  19287   testget1: &amp;lt;--- TRN:  0000002481540150632034-AERG00001A - S from [RCV.FROM.TEST.SEP.Q1@QM.ABC123]." ]
| append [ | makeresults | eval _raw="240105 18:06:03  19287   testget1: &amp;lt;--- TRN:  0000002400547150635213-AERG00000A - S from [RCV.FROM.TEST.SEP.Q1@QM.ABC123]. "]
| append [ | makeresults | eval _raw="240105 18:02:29  72965   testget1: ===&amp;gt; TRN@instance.RQ1:  0000002400540902427245-AERC000f8A [Priority=Medium,ScanPriority=2, Rule: Default Rule]." ]
| append [ | makeresults | eval _raw="240105 18:02:29  72965   testget1: ===&amp;gt; TRN@instance.RQ1:  0000001800540152427236-AERC000f7A [Priority=Medium,ScanPriority=2, Rule: Default Rule]."]
| append [ | makeresults | eval _raw="240105 18:02:29  72965   testget1: ===&amp;gt; TRN@instance.RQ1:  0000002400540109427216-AERC000f6A [Priority=High,ScanPriority=1, Rule: Default Rule]." ]
| rex "\:  (?&amp;lt;testgettrn&amp;gt;.*) \- S from"  
| rex "RCV\.FROM\.(?&amp;lt;TestMQ&amp;gt;.*)\@"
| rex field=TestMQ "\w+\.\w+\.(?&amp;lt;key&amp;gt;\w+)"
| rex "TRN\@instance\.R(?&amp;lt;key&amp;gt;[^:]++):"
| rex "Priority\=(?&amp;lt;Priority&amp;gt;\w+)"
| stats values(TestMQ) AS TestMQ count(eval(Priority="Low")) as Low, count(eval(Priority="Medium")) as Medium, count(eval(Priority="High")) as High BY key
| fields - key
| fillnull value=0
| addtotals&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jan 2024 09:09:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673504#M230622</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2024-01-08T09:09:55Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk stats count group by multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673516#M230623</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;- Thank you for you continuos support. I am able to proceed next with your suggestion but now stuck at one point. Need your help on it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kindly suggest.&lt;/P&gt;&lt;P&gt;Query Used:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=test_index source=*instance*/*testget*
| rex "\:  (?&amp;lt;testgettrn&amp;gt;.*) \- S from"  
| rex "RCV\.FROM\.(?&amp;lt;TestMQ&amp;gt;.*)\@"
| rex field=TestMQ "\w+\.\w+\.(?&amp;lt;key&amp;gt;\w+)"
| rex "TRN\@\\w+\.R(?&amp;lt;key&amp;gt;[^:]++):"
| rex "Priority\=(?&amp;lt;Priority&amp;gt;\w+)"
| stats values(TestMQ) AS TestMQ count(eval(Priority="Low")) as Low, count(eval(Priority="Medium")) as Medium, count(eval(Priority="High")) as High BY key
| fillnull value=0
| addtotals&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Getting results as below:&lt;BR /&gt;&lt;BR /&gt;Total count (Q1+Q2) is getting added to Q1 only. And Q2 is remaining null (as shown in below example)&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;key | TestMQ          | Low | Medium | High | Total
Q1  | TEST.SEP.Q1     | 20  | 20     | 30   | 70
    | TEST.SEP2.Q1    
    | TEST.SEP3.Q1    

Q2  | TEST.SEP.Q2    | 0 | 0 | 0 | 0
    | TEST.SEP2.Q2   
    | TEST.SEP3.Q2  &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Please guide and suggest.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jan 2024 11:49:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673516#M230623</guid>
      <dc:creator>shashankk</dc:creator>
      <dc:date>2024-01-08T11:49:07Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk stats count group by multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673518#M230624</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/258022"&gt;@shashankk&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;as I said, the problem is to identify a key contained in both the types of your logs: the ones with the TestMQ field and the ones containing Priority filed.&lt;/P&gt;&lt;P&gt;I identified, from your sample few logs the regex to extract Q1 or Q2 or Q3, but evidently it isn't sufficient.&lt;/P&gt;&lt;P&gt;can you identify a common key to use for correlation?&lt;/P&gt;&lt;P&gt;If you haven't this common key it's very hard to correlate events without any relation.&lt;/P&gt;&lt;P&gt;Maybe, if you could share more samples, with more TestMQ, I could help you in key identification and extraction, but anyway, the only approach I see is the one I described: find a common key for correlation.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jan 2024 12:11:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673518#M230624</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2024-01-08T12:11:06Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk stats count group by multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673521#M230626</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I have added below more lines of the sample event file - please help me find the right key.&lt;BR /&gt;&lt;BR /&gt;Or if not possible with the correlation Key - how to proceed with the JOIN in this case?&lt;BR /&gt;&lt;BR /&gt;Kindly guide and suggest.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;240108 07:12:07  17709   testget1: ===&amp;gt; TRN@instance2.RQ1:  0000002400840162931785-AHGM0000bA [Priority=Low,ScanPriority=0, Rule: Default Rule].
240108 07:12:07  17709   testget1: &amp;lt;--- TRN:  0000002400840162929525-AHGM00015A - S from [RCV.FROM.TEST.SEP2.Q2@QM.ABCD101].&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2024 09:38:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673521#M230626</guid>
      <dc:creator>shashankk</dc:creator>
      <dc:date>2024-01-09T09:38:57Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk stats count group by multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673525#M230629</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/258022"&gt;@shashankk&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;source="MQlogs.txt" host="test" sourcetype="MQ" 
| rex "\:  (?&amp;lt;testgettrn&amp;gt;.*) \- S from"  
| rex "RCV\.FROM\.(?&amp;lt;TestMQ&amp;gt;.*)\@"
| rex field=TestMQ "\w+\.\w+\.(?&amp;lt;key&amp;gt;\w+)"
| rex "TRN\@\\w+\.R(?&amp;lt;key&amp;gt;[^:]++):"
| rex "Priority\=(?&amp;lt;Priority&amp;gt;\w+)"
|table _raw TestMQ key priority
```| stats values(TestMQ) AS TestMQ count(eval(Priority="Low")) as Low, count(eval(Priority="Medium")) as Medium, count(eval(Priority="High")) as High BY key
| fillnull value=0
| addtotals```&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you pls run this and update us the results screenshot.. when i run this one, the priority is not extracted. looks like something wrong. pls suggest, thanks.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jan 2024 13:13:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673525#M230629</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2024-01-08T13:13:43Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk stats count group by multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673527#M230630</link>
      <description>&lt;P&gt;Since you have provided more sample data and stated what the common field across the events are, I think a search like this may work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;base_search&amp;gt;
    | rex field=_raw "Priority\=(?&amp;lt;Priority&amp;gt;[^\,]+)"
    | rex "(?:\={3}\&amp;gt;|\&amp;lt;\-{3})\s+TRN[^\:]*\:\s+(?&amp;lt;trn&amp;gt;[^\s]+)"
    | rex "RCV\.FROM\.(?&amp;lt;TestMQ&amp;gt;.*)\@"
    | stats
        count(eval(Priority=="Low")) as Low,
        count(eval(Priority=="Medium")) as Medium,
        count(eval(Priority=="High")) as High,
        values(TestMQ) as TestMQ
            by trn
    | stats
        sum(Low) as Low,
        sum(Medium) as Medium,
        sum(High) as High
            by TestMQ
    | addtotals fieldname="TotalCount"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;This is what the final result looks like running against the sample data you provided.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dtburrows3_0-1704720817900.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28789iCC43EED41D685BE9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dtburrows3_0-1704720817900.png" alt="dtburrows3_0-1704720817900.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jan 2024 13:34:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-group-by-multiple-fields/m-p/673527#M230630</guid>
      <dc:creator>dtburrows3</dc:creator>
      <dc:date>2024-01-08T13:34:35Z</dc:date>
    </item>
  </channel>
</rss>

