<?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: Create a table with emails sent and emails received from a given emails addresses in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-with-emails-sent-and-emails-received-from/m-p/620040#M215521</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/245749"&gt;@JLopez&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can also try this search. Just go through each statement to get more on logic.&lt;/P&gt;&lt;P&gt;Here have assumed that&amp;nbsp;Recipients may have multiple emails by a comma separated. So you can change the search as per your values in the Recipients fields.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;YOUR_SEARCH
| eval Recipients = split(Recipients,",")
| eval EmailAddress = mvappend(Recipients,Sender)
| mvexpand EmailAddress
| eval Recipients_flg = if(Recipients=EmailAddress,1,0)
| eval Sender_flg = if(Sender=EmailAddress,1,0)
| stats sum(Recipients_flg) as "Emails received" sum(Sender_flg) as "Emails sent" by EmailAddress&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My Sample Search :&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval _raw="data
bob1@splunk.com,bob10@splunk.com|bob2@splunk.com
bob1@splunk.com|bob3@splunk.com
bob2@splunk.com|bob1@splunk.com
bob2@splunk.com|bob3@splunk.com
bob3@splunk.com|bob1@splunk.com
bob3@splunk.com|bob2@splunk.com" 
| multikv forceheader=1
| eval Recipients=mvindex(split(data,"|"),0),Sender=mvindex(split(data,"|"),1)
| table Recipients,Sender
| rename comment as "upto this is sample data" 
| eval Recipients = split(Recipients,",")
| eval EmailAddress = mvappend(Recipients,Sender)
| mvexpand EmailAddress
| eval Recipients_flg = if(Recipients=EmailAddress,1,0)
| eval Sender_flg = if(Sender=EmailAddress,1,0)
| stats sum(Recipients_flg) as "Emails received" sum(Sender_flg) as "Emails sent" by EmailAddress&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2022-11-08 at 10.43.01 AM.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/22390iF4A4DA460340E2DE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2022-11-08 at 10.43.01 AM.png" alt="Screenshot 2022-11-08 at 10.43.01 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I hope this will help you. &lt;/P&gt;&lt;P&gt;Thanks&lt;BR /&gt;KV&lt;BR /&gt;If any of my replies help you to solve the problem Or gain knowledge, an upvote would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 08 Nov 2022 05:13:23 GMT</pubDate>
    <dc:creator>kamlesh_vaghela</dc:creator>
    <dc:date>2022-11-08T05:13:23Z</dc:date>
    <item>
      <title>How to create a table with emails sent and emails received from a given emails addresses?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-with-emails-sent-and-emails-received-from/m-p/620006#M215502</link>
      <description>&lt;P data-unlink="true"&gt;Hi Guys,&lt;BR /&gt;&lt;BR /&gt;I'm trying to create a table&amp;nbsp;with the count emails sent and emails received from a given emails addresses&lt;BR /&gt;&lt;BR /&gt;Column 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Column 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Column 3&lt;BR /&gt;Email addresses&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Emails received&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; email sent&amp;nbsp;&lt;BR /&gt;bob1@splunk.com&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Number&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Number&amp;gt;&lt;BR /&gt;bob2@splunk.com&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;lt;Number&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Number&amp;gt;&lt;BR /&gt;&lt;BR /&gt;I tried this with append command but the result are shown under one another&lt;BR /&gt;&lt;BR /&gt;my search is&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;index=email_index Recipients IN(bob1@splunk.com, bob2@splunk.com, bob3@splunk.com )&amp;nbsp;&lt;BR /&gt;|stats count as "Emails received" by Recipients&lt;BR /&gt;| append&lt;BR /&gt;[search index=email_index Sender IN(bob1@splunk.com, bob2@splunk.com,&amp;nbsp; bob3@splunk.com )&amp;nbsp;&lt;BR /&gt;|stats count as "Emails sent" by Sender]&lt;BR /&gt;|table "Emails received" "Emails sent"&amp;nbsp; Recipients Sender&lt;BR /&gt;&lt;BR /&gt;Anyone can help me please?&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2022 16:03:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-with-emails-sent-and-emails-received-from/m-p/620006#M215502</guid>
      <dc:creator>JLopez</dc:creator>
      <dc:date>2022-11-08T16:03:25Z</dc:date>
    </item>
    <item>
      <title>Re: Create a table with emails sent and emails received from a given emails addresses</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-with-emails-sent-and-emails-received-from/m-p/620013#M215504</link>
      <description>&lt;P&gt;Simple version&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=email_index Recipients IN(bob1@splunk.com, bob2@splunk.com, bob3@splunk.com ) 
| stats count as "Emails received" by Recipients 
| rename Recipients as EmailAddress 
| append 
    [ search index=email_index Sender IN(bob1@splunk.com, bob2@splunk.com, bob3@splunk.com ) 
    | stats count as "Emails sent" by Sender
    | rename Sender as EmailAddress
    ] 
| stats values(*) as * by EmailAddress&lt;/LI-CODE&gt;&lt;P&gt;may be possible to do it with a single search, i.e. without append, but would need more thought.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2022 01:03:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-with-emails-sent-and-emails-received-from/m-p/620013#M215504</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-11-08T01:03:43Z</dc:date>
    </item>
    <item>
      <title>Re: Create a table with emails sent and emails received from a given emails addresses</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-with-emails-sent-and-emails-received-from/m-p/620035#M215519</link>
      <description>&lt;P&gt;Any particular reason to use append? &amp;nbsp;Simple stats seems better suited.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=email_index (Recipients=* OR Sender=*)
| eval EmailAddress = coalesce(Recipients, Sender)
| stats count(Recipients) as "Emails received" count(Sender) as "Emails sent" by EmailAddress&lt;/LI-CODE&gt;&lt;P&gt;If you only want data on three E-mails, you can use IN instead of =*.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2022 04:32:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-with-emails-sent-and-emails-received-from/m-p/620035#M215519</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-11-08T04:32:12Z</dc:date>
    </item>
    <item>
      <title>Re: Create a table with emails sent and emails received from a given emails addresses</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-with-emails-sent-and-emails-received-from/m-p/620040#M215521</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/245749"&gt;@JLopez&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can also try this search. Just go through each statement to get more on logic.&lt;/P&gt;&lt;P&gt;Here have assumed that&amp;nbsp;Recipients may have multiple emails by a comma separated. So you can change the search as per your values in the Recipients fields.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;YOUR_SEARCH
| eval Recipients = split(Recipients,",")
| eval EmailAddress = mvappend(Recipients,Sender)
| mvexpand EmailAddress
| eval Recipients_flg = if(Recipients=EmailAddress,1,0)
| eval Sender_flg = if(Sender=EmailAddress,1,0)
| stats sum(Recipients_flg) as "Emails received" sum(Sender_flg) as "Emails sent" by EmailAddress&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My Sample Search :&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval _raw="data
bob1@splunk.com,bob10@splunk.com|bob2@splunk.com
bob1@splunk.com|bob3@splunk.com
bob2@splunk.com|bob1@splunk.com
bob2@splunk.com|bob3@splunk.com
bob3@splunk.com|bob1@splunk.com
bob3@splunk.com|bob2@splunk.com" 
| multikv forceheader=1
| eval Recipients=mvindex(split(data,"|"),0),Sender=mvindex(split(data,"|"),1)
| table Recipients,Sender
| rename comment as "upto this is sample data" 
| eval Recipients = split(Recipients,",")
| eval EmailAddress = mvappend(Recipients,Sender)
| mvexpand EmailAddress
| eval Recipients_flg = if(Recipients=EmailAddress,1,0)
| eval Sender_flg = if(Sender=EmailAddress,1,0)
| stats sum(Recipients_flg) as "Emails received" sum(Sender_flg) as "Emails sent" by EmailAddress&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2022-11-08 at 10.43.01 AM.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/22390iF4A4DA460340E2DE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2022-11-08 at 10.43.01 AM.png" alt="Screenshot 2022-11-08 at 10.43.01 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I hope this will help you. &lt;/P&gt;&lt;P&gt;Thanks&lt;BR /&gt;KV&lt;BR /&gt;If any of my replies help you to solve the problem Or gain knowledge, an upvote would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2022 05:13:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-with-emails-sent-and-emails-received-from/m-p/620040#M215521</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2022-11-08T05:13:23Z</dc:date>
    </item>
    <item>
      <title>Re: Create a table with emails sent and emails received from a given emails addresses</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-with-emails-sent-and-emails-received-from/m-p/620047#M215526</link>
      <description>&lt;P&gt;It looks like the reason for the append is that the data is in a single event per email and recipients is MV, so coalesce will always yield Recipients&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2022 06:35:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-with-emails-sent-and-emails-received-from/m-p/620047#M215526</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-11-08T06:35:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a table with emails sent and emails received from a given emails addresses?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-with-emails-sent-and-emails-received-from/m-p/620565#M215728</link>
      <description>&lt;P&gt;thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;this worked for me and the visualization is within the same rows! ( that was my pain )&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Appreciate your time and expertise!&lt;BR /&gt;&lt;BR /&gt;why are you using the * within the values??&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2022 10:23:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-with-emails-sent-and-emails-received-from/m-p/620565#M215728</guid>
      <dc:creator>JLopez</dc:creator>
      <dc:date>2022-11-11T10:23:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a table with emails sent and emails received from a given emails addresses?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-with-emails-sent-and-emails-received-from/m-p/620688#M215767</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/245749"&gt;@JLopez&lt;/a&gt;&amp;nbsp;Using wildcards is a simple way of shortcutting typing out all the field names.&lt;/P&gt;&lt;P&gt;After the first query and second queries, you have 3 fields, "Emails Sent", "Emails Received" and EmailAddress.&lt;/P&gt;&lt;P&gt;You could do it long hand and do&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats values("Emails Sent") as "Emails Sent" values("Emails Received") as "Emails Received" by EmailAddress&lt;/LI-CODE&gt;&lt;P&gt;but you don't need to.&lt;/P&gt;&lt;P&gt;Also, using wildcards for field selections promotes good use of field naming conventions, in that you can use techniques such as partial wildcards to select certain groups of field names, e.g. count_* to reference all fields with the starting text "count_"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 13 Nov 2022 22:17:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-with-emails-sent-and-emails-received-from/m-p/620688#M215767</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-11-13T22:17:28Z</dc:date>
    </item>
  </channel>
</rss>

