<?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: How to Sort data by using the value of Variable Name in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-Sort-data-by-using-the-value-of-Variable-Name/m-p/630625#M219091</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/253693"&gt;@sukansingh&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;good for you, see next time!&lt;/P&gt;&lt;P&gt;Ciao and happy splunking&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;P.S.: Karma Points are appreciated by all the contributors &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 13 Feb 2023 11:00:07 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2023-02-13T11:00:07Z</dc:date>
    <item>
      <title>How to Sort data by using the value of Variable Name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Sort-data-by-using-the-value-of-Variable-Name/m-p/630586#M219077</link>
      <description>&lt;P&gt;I have a query and at the end I want to sort the data by specific column But column is dynamically generated. i can get the column name in eval function and store it in variable. Now to use this variable in sort command?&lt;/P&gt;&lt;P&gt;for example &lt;EM&gt;my_search | eval date="my logic &amp;amp; let say return '2023-02-02'" | &lt;STRONG&gt;sort - $date &lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;here variable is holding the column_name value and then I want to sort by that column.&lt;/P&gt;&lt;P&gt;Is it possible to sort by column name which is dynamically generated So i won't know the exact name But variable holds the column name So I can just use &lt;STRONG&gt;&lt;EM&gt;sort - $Variable&lt;/EM&gt;&lt;/STRONG&gt;?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2023 06:30:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Sort-data-by-using-the-value-of-Variable-Name/m-p/630586#M219077</guid>
      <dc:creator>sukansingh</dc:creator>
      <dc:date>2023-02-13T06:30:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to Sort data by using the value of Variable Name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Sort-data-by-using-the-value-of-Variable-Name/m-p/630587#M219078</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/253693"&gt;@sukansingh&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;your request isn't so clear for me because using the search you shared it's easy to sort for the date field:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;my_search 
| eval date="my logic &amp;amp; let say return '2023-02-02'" 
| sort -date&lt;/LI-CODE&gt;&lt;P&gt;if instead the problem is that you haven't a name defined field to sort, you have to find a workaround related to your search, could you share your real search?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2023 06:58:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Sort-data-by-using-the-value-of-Variable-Name/m-p/630587#M219078</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-02-13T06:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to Sort data by using the value of Variable Name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Sort-data-by-using-the-value-of-Variable-Name/m-p/630603#M219082</link>
      <description>&lt;P&gt;&lt;EM&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;I have a below Query-&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;index="services" statusCode="500" | bucket _time span=day | eval time=strftime(_time,"%F") | chart count by customerId,time&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Result shown in below screenshot, and I want to sort by last column. Somehow I evaluated what would be column name with below eval function-&lt;/P&gt;&lt;P&gt;&lt;EM&gt;| eval max="1900-01-01", reg="^\d{4}-\d{2}-\d{2}$" | foreach * [eval col="&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;", max=if(match(col,reg), if(col&amp;gt;max,col,max) ,max)] | &lt;STRONG&gt;sort - max&lt;/STRONG&gt; | fields - col max reg&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;But in above query , sort -max is not working for me.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sukansingh_0-1676274514548.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/23840i59F257F14B206D3A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sukansingh_0-1676274514548.png" alt="sukansingh_0-1676274514548.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm just looking for a solution to sort this dynamically generated column through query.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2023 07:48:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Sort-data-by-using-the-value-of-Variable-Name/m-p/630603#M219082</guid>
      <dc:creator>sukansingh</dc:creator>
      <dc:date>2023-02-13T07:48:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to Sort data by using the value of Variable Name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Sort-data-by-using-the-value-of-Variable-Name/m-p/630607#M219083</link>
      <description>&lt;P&gt;&lt;SPAN&gt;If it is always the last / latest column, you could try something like this&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| sort 0
    [| makeresults
    | addinfo 
    | eval search=strftime(info_max_time-1, "%F")
    | fields search
    | tail 1
    | format "" "" "" "" "" ""]&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 13 Feb 2023 08:05:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Sort-data-by-using-the-value-of-Variable-Name/m-p/630607#M219083</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-02-13T08:05:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to Sort data by using the value of Variable Name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Sort-data-by-using-the-value-of-Variable-Name/m-p/630608#M219084</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/253693"&gt;@sukansingh&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;youcould use the solution from&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;that's correct or use a different approach:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="services" statusCode="500" 
| timechart span=1d count by customerId&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2023 08:15:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Sort-data-by-using-the-value-of-Variable-Name/m-p/630608#M219084</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-02-13T08:15:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to Sort data by using the value of Variable Name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Sort-data-by-using-the-value-of-Variable-Name/m-p/630625#M219091</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/253693"&gt;@sukansingh&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;good for you, see next time!&lt;/P&gt;&lt;P&gt;Ciao and happy splunking&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;P.S.: Karma Points are appreciated by all the contributors &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2023 11:00:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Sort-data-by-using-the-value-of-Variable-Name/m-p/630625#M219091</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-02-13T11:00:07Z</dc:date>
    </item>
  </channel>
</rss>

