<?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 sort strings based off a dictionary of values? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-strings-based-off-a-dictionary-of-values/m-p/345689#M102410</link>
    <description>&lt;P&gt;Hi &amp;amp; thanks in advance for reading,&lt;/P&gt;

&lt;P&gt;I have a table as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;email                              event
----------------------------------------------
I-got-delivered@example.com     deferred    
I-got-delivered@example.com     delivered
I-got-delivered@example.com     processed
I-bounced@example.com             deferred  
I-bounced@example.com             processed 
I-bounced@example.com             bounced   
Im-processing@example.com         deferred
Im-processing@example.com         processed
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;where the events are ordered as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{
    1: 'deferred',
    2: 'processed'
    3: 'bounced',
    4: 'delivered'
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want group by the email, compare the events and return only the max value for event (i.e. deferred &amp;lt; processed &amp;lt; bounced &amp;lt; delivered). The table should look like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;I-got-delivered@example.com     delivered
I-bounced@example.com           bounced 
Im-processing@example.com       processed
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I was thinking I could do it with lots of nested if statements, but I was wondering if there's a more elegant way to do it. How would you achieve this?&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
fre&lt;/P&gt;</description>
    <pubDate>Thu, 21 Sep 2017 18:49:19 GMT</pubDate>
    <dc:creator>fre</dc:creator>
    <dc:date>2017-09-21T18:49:19Z</dc:date>
    <item>
      <title>How to sort strings based off a dictionary of values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-strings-based-off-a-dictionary-of-values/m-p/345689#M102410</link>
      <description>&lt;P&gt;Hi &amp;amp; thanks in advance for reading,&lt;/P&gt;

&lt;P&gt;I have a table as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;email                              event
----------------------------------------------
I-got-delivered@example.com     deferred    
I-got-delivered@example.com     delivered
I-got-delivered@example.com     processed
I-bounced@example.com             deferred  
I-bounced@example.com             processed 
I-bounced@example.com             bounced   
Im-processing@example.com         deferred
Im-processing@example.com         processed
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;where the events are ordered as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{
    1: 'deferred',
    2: 'processed'
    3: 'bounced',
    4: 'delivered'
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want group by the email, compare the events and return only the max value for event (i.e. deferred &amp;lt; processed &amp;lt; bounced &amp;lt; delivered). The table should look like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;I-got-delivered@example.com     delivered
I-bounced@example.com           bounced 
Im-processing@example.com       processed
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I was thinking I could do it with lots of nested if statements, but I was wondering if there's a more elegant way to do it. How would you achieve this?&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
fre&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 18:49:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-strings-based-off-a-dictionary-of-values/m-p/345689#M102410</guid>
      <dc:creator>fre</dc:creator>
      <dc:date>2017-09-21T18:49:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort strings based off a dictionary of values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-strings-based-off-a-dictionary-of-values/m-p/345690#M102411</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your current search giving above table with field email, event
| replace "deferred" with 1 "processed" with 2 "bounced" with 3 "delivered" with 4 in event
| stats max(event) as event by email 
| replace "1" with "deferred" "2" with "processed" "3" with "bounced" "4" with "delivered" in event
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Sep 2017 19:51:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-strings-based-off-a-dictionary-of-values/m-p/345690#M102411</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-09-21T19:51:50Z</dc:date>
    </item>
  </channel>
</rss>

