<?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: Sort by date in Reporting</title>
    <link>https://community.splunk.com/t5/Reporting/Sort-by-date/m-p/525715#M8525</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/227934"&gt;@AnguaSec&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;what's the forma of your timeStr field?&lt;/P&gt;&lt;P&gt;if it's dd/mm/yyyy, you should try something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval epoch_timeStr=strptime(timeStr,"%d/%m/Y")
| sort epoch_timeStr&lt;/LI-CODE&gt;&lt;P&gt;in other words, the formt to use in strptime is the one of the field timeStr.&lt;/P&gt;&lt;P&gt;To know the time variables see at&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.0.6/SearchReference/Commontimeformatvariables" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/8.0.6/SearchReference/Commontimeformatvariables&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
    <pubDate>Wed, 21 Oct 2020 09:00:38 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2020-10-21T09:00:38Z</dc:date>
    <item>
      <title>Sort by date</title>
      <link>https://community.splunk.com/t5/Reporting/Sort-by-date/m-p/525706#M8524</link>
      <description>&lt;P&gt;I have updated a csv file and one of the fields is a date.&amp;nbsp; &amp;nbsp;I need to sort the data by date order then I can visualise a graph with it but it won't sort by date.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've read the posts about changing to Epoch&amp;nbsp; time then sorting or using strftime, etc, but none of them have worked.&lt;/P&gt;&lt;P&gt;I found the answer on how to change the field data to show as a date which worked is this&lt;/P&gt;&lt;P&gt;eval "booking Date"=strptime(timeStr, "%d %m %Y") |sort "Booking Date"&lt;/P&gt;&lt;P&gt;How do I then sort by date?&lt;/P&gt;</description>
      <pubDate>Wed, 21 Oct 2020 08:25:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/Sort-by-date/m-p/525706#M8524</guid>
      <dc:creator>AnguaSec</dc:creator>
      <dc:date>2020-10-21T08:25:42Z</dc:date>
    </item>
    <item>
      <title>Re: Sort by date</title>
      <link>https://community.splunk.com/t5/Reporting/Sort-by-date/m-p/525715#M8525</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/227934"&gt;@AnguaSec&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;what's the forma of your timeStr field?&lt;/P&gt;&lt;P&gt;if it's dd/mm/yyyy, you should try something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval epoch_timeStr=strptime(timeStr,"%d/%m/Y")
| sort epoch_timeStr&lt;/LI-CODE&gt;&lt;P&gt;in other words, the formt to use in strptime is the one of the field timeStr.&lt;/P&gt;&lt;P&gt;To know the time variables see at&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.0.6/SearchReference/Commontimeformatvariables" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/8.0.6/SearchReference/Commontimeformatvariables&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 21 Oct 2020 09:00:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/Sort-by-date/m-p/525715#M8525</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-10-21T09:00:38Z</dc:date>
    </item>
    <item>
      <title>Re: Sort by date</title>
      <link>https://community.splunk.com/t5/Reporting/Sort-by-date/m-p/525719#M8527</link>
      <description>&lt;P&gt;Yes the date format is&amp;nbsp;&lt;SPAN&gt;dd/mm/yyyy.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Where in the query you've given the example on would I put the field name?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Oct 2020 09:32:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/Sort-by-date/m-p/525719#M8527</guid>
      <dc:creator>AnguaSec</dc:creator>
      <dc:date>2020-10-21T09:32:08Z</dc:date>
    </item>
    <item>
      <title>Re: Sort by date</title>
      <link>https://community.splunk.com/t5/Reporting/Sort-by-date/m-p/525720#M8528</link>
      <description>&lt;P class="lia-align-justify"&gt;I replaced&amp;nbsp;&lt;SPAN&gt;timeStr with my field name is that right?&amp;nbsp; It still doesn't work.&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="lia-align-justify"&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Oct 2020 09:39:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/Sort-by-date/m-p/525720#M8528</guid>
      <dc:creator>AnguaSec</dc:creator>
      <dc:date>2020-10-21T09:39:06Z</dc:date>
    </item>
    <item>
      <title>Re: Sort by date</title>
      <link>https://community.splunk.com/t5/Reporting/Sort-by-date/m-p/525725#M8530</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/227934"&gt;@AnguaSec&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;this is an example to adapt to your needs.&lt;/P&gt;&lt;P&gt;To help you, could you share your search and a sample of data?&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 21 Oct 2020 09:43:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/Sort-by-date/m-p/525725#M8530</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-10-21T09:43:36Z</dc:date>
    </item>
    <item>
      <title>Re: Sort by date</title>
      <link>https://community.splunk.com/t5/Reporting/Sort-by-date/m-p/525727#M8531</link>
      <description>&lt;P&gt;Hi gcusello&lt;/P&gt;&lt;P&gt;Thanks for helping on this.&lt;/P&gt;&lt;P&gt;The original search I did trying to sort by date is&amp;nbsp;&lt;/P&gt;&lt;P&gt;source="Book7.csv" host="xxxxx" sourcetype="csv"| chart sum(Cost) sum(Total) over "Booking Date" | eval "booking Date"=strptime(timeStr, "%d %m %Y") |sort "Booking Date"&lt;/P&gt;&lt;P&gt;The data is from a column with booking dates, a column with costs and column with the total costs.&lt;/P&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="AnguaSec_0-1603273764826.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/11397iC34C64C9AEA48EC1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AnguaSec_0-1603273764826.png" alt="AnguaSec_0-1603273764826.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;When I changed the last bit it still did the same thing, just sorts by day.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&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;</description>
      <pubDate>Wed, 21 Oct 2020 09:52:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/Sort-by-date/m-p/525727#M8531</guid>
      <dc:creator>AnguaSec</dc:creator>
      <dc:date>2020-10-21T09:52:14Z</dc:date>
    </item>
    <item>
      <title>Re: Sort by date</title>
      <link>https://community.splunk.com/t5/Reporting/Sort-by-date/m-p/525752#M8534</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/227934"&gt;@AnguaSec&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;beware that field names are case sensitive and in your search you have:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;"booking Date"&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;instead of&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;"Booking Date"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Then it's wrong the time format in strptime function.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So try something like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;source="Book7.csv" host="xxxxx" sourcetype="csv"
| chart sum(Cost) AS Cost sum(Total) As Total over "Booking Date" 
| eval "Booking Date"=strptime(timeStr,"%d/%m/%Y") 
| sort "Booking Date"
| eval "Booking Date"=strftime(timeStr,"%d/%m/%Y") &lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;Two additional hints: &lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;use always "index=your_index" in your main search: you'll have quicker searches,&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;if possible, avoid fields with spaces in the field names: "Booking_Date" is better than "Booking Date", at the end of the search you can rename that field using the label you like.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;Ciao.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Giuseppe&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Oct 2020 11:13:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/Sort-by-date/m-p/525752#M8534</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-10-21T11:13:43Z</dc:date>
    </item>
    <item>
      <title>Re: Sort by date</title>
      <link>https://community.splunk.com/t5/Reporting/Sort-by-date/m-p/525760#M8535</link>
      <description>&lt;P&gt;Hi gcusello&lt;/P&gt;&lt;P&gt;Thank you.&amp;nbsp; I know the fields are case sensitive but for some reason when I change them all to be the same the date disappears completely.&amp;nbsp; See below.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AnguaSec_0-1603280361222.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/11408iE24152DA5D749879/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AnguaSec_0-1603280361222.png" alt="AnguaSec_0-1603280361222.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;When I change all but the first to b instead of B it works&lt;/P&gt;&lt;P&gt;over "Booking Date" | eval "booking Date"=strptime(timeStr,"%d/%m/%Y")&lt;BR /&gt;| sort "booking Date"&lt;BR /&gt;| eval "booking Date"=strftime(timeStr,"%d/%m/%Y")&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AnguaSec_1-1603280466302.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/11409i3DB5E0B43FF687C7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AnguaSec_1-1603280466302.png" alt="AnguaSec_1-1603280466302.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;but that still won't sort the booking dates in order.&lt;/P&gt;&lt;P&gt;Although I know it's better to not have gaps in the field names the field names have come from the spreadsheet but it's too complicated to work on sorting and renaming at the same time so I want to sort the date order issue out first.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Oct 2020 11:44:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/Sort-by-date/m-p/525760#M8535</guid>
      <dc:creator>AnguaSec</dc:creator>
      <dc:date>2020-10-21T11:44:03Z</dc:date>
    </item>
    <item>
      <title>Re: Sort by date</title>
      <link>https://community.splunk.com/t5/Reporting/Sort-by-date/m-p/525762#M8536</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/227934"&gt;@AnguaSec&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;in my Splunk it runs but probably I have different data!&lt;/P&gt;&lt;P&gt;Anyway, please try this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;source="Book7.csv" host="xxxxx" sourcetype="csv"
| eval "Booking Date"=strptime(timeStr,"%d/%m/%Y") 
| chart sum(Cost) AS Cost sum(Total) As Total over "Booking Date" 
| sort -"Booking Date"
| eval "Booking Date"=strftime(timeStr,"%d/%m/%Y") &lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 21 Oct 2020 12:20:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/Sort-by-date/m-p/525762#M8536</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-10-21T12:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: Sort by date</title>
      <link>https://community.splunk.com/t5/Reporting/Sort-by-date/m-p/525765#M8537</link>
      <description>&lt;P&gt;It's strange isn't it?&lt;/P&gt;&lt;P&gt;Thank you for trying to help but that's not worked either.&amp;nbsp; I think I'll have to rethink how we use the original data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks&lt;/P&gt;</description>
      <pubDate>Wed, 21 Oct 2020 12:28:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/Sort-by-date/m-p/525765#M8537</guid>
      <dc:creator>AnguaSec</dc:creator>
      <dc:date>2020-10-21T12:28:10Z</dc:date>
    </item>
    <item>
      <title>Re: Sort by date</title>
      <link>https://community.splunk.com/t5/Reporting/Sort-by-date/m-p/525785#M8538</link>
      <description>&lt;P&gt;Hi gcusello&lt;/P&gt;&lt;P&gt;I've managed to sort the data in date order by changing the date to epoch time which works great for the Statistics page but because the Epoch Time is showing on the graph it won't show the costs on the graph as well.&amp;nbsp; &amp;nbsp;Any idea how to remove the epoch time after adding it without it taking away all the data?&lt;/P&gt;&lt;P&gt;This is the query i used to enable sorting by date&lt;/P&gt;&lt;P&gt;source="Book7.csv" host="xxxx" sourcetype="csv"| chart sum(Cost) sum(Total) over "Booking Date" | rename "Booking Date" AS Booking_Date | convert timeformat="%d/%m/%Y" mktime(Booking_Date) as "ConvertedEpochTime" | sort "ConvertedEpochTime"&lt;/P&gt;&lt;P&gt;This is how the data looks in Statistics&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AnguaSec_0-1603287032817.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/11410i7310288195CE0D52/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AnguaSec_0-1603287032817.png" alt="AnguaSec_0-1603287032817.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I need to remove the data in the last column for the graphs.&amp;nbsp; Any ideas?&lt;/P&gt;</description>
      <pubDate>Wed, 21 Oct 2020 13:30:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/Sort-by-date/m-p/525785#M8538</guid>
      <dc:creator>AnguaSec</dc:creator>
      <dc:date>2020-10-21T13:30:57Z</dc:date>
    </item>
    <item>
      <title>Re: Sort by date</title>
      <link>https://community.splunk.com/t5/Reporting/Sort-by-date/m-p/525790#M8539</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/227934"&gt;@AnguaSec&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;did you already tried with&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| fields - ConvertedEpochTime&lt;/LI-CODE&gt;&lt;P&gt;?&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 21 Oct 2020 13:36:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/Sort-by-date/m-p/525790#M8539</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-10-21T13:36:55Z</dc:date>
    </item>
    <item>
      <title>Re: Sort by date</title>
      <link>https://community.splunk.com/t5/Reporting/Sort-by-date/m-p/525793#M8540</link>
      <description>&lt;P&gt;I Hadn't.&amp;nbsp; That worked.&amp;nbsp; &amp;nbsp;Thank you so much.&amp;nbsp; &amp;nbsp;Got there in the end&amp;nbsp;&lt;/P&gt;&lt;P&gt;:):):)&lt;/P&gt;</description>
      <pubDate>Wed, 21 Oct 2020 13:39:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/Sort-by-date/m-p/525793#M8540</guid>
      <dc:creator>AnguaSec</dc:creator>
      <dc:date>2020-10-21T13:39:53Z</dc:date>
    </item>
    <item>
      <title>Re: Sort by date</title>
      <link>https://community.splunk.com/t5/Reporting/Sort-by-date/m-p/525817#M8542</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/227934"&gt;@AnguaSec&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;good for you,&lt;/P&gt;&lt;P&gt;if this answer solves your need, please, accept it for the other people of Community.&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 &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Oct 2020 14:30:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/Sort-by-date/m-p/525817#M8542</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-10-21T14:30:45Z</dc:date>
    </item>
  </channel>
</rss>

