<?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: Total spend per field per month in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Total-spend-per-field-per-month/m-p/674784#M230974</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/258512"&gt;@PaulaCom&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;Here's a way to convert your date to "Jan", "Feb" etc:&lt;BR /&gt;strftime(date_field, format) &lt;A href="https://docs.splunk.com/Documentation/SCS/current/SearchReference/DateandTimeFunctions#strftime.28.26lt.3Btime.26gt.3B.2C.26lt.3Bformat.26gt.3B.29" target="_self"&gt;see docs&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;We can use the field Order_Date like this:&lt;BR /&gt;eval month&amp;nbsp;= strftime(strptime(Order_Date, "%d/%m/%Y"), "%b")&lt;BR /&gt;&lt;BR /&gt;That adds another step of converting the date to a unix timestamp, then converting that timestamp to the Month in english.&lt;BR /&gt;&lt;BR /&gt;Now that we have the month, we can make it a field by using special curly brackets:&lt;BR /&gt;&lt;BR /&gt;| eval {month} = Total&lt;BR /&gt;&lt;BR /&gt;That will create a field called "Jan" or "Feb" with the value of the total for sales.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Here's the Search all together:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;|makeresults | eval data="Account_No=\"123\", Total=\"15.00\", Order_Date=\"1/01/2023\"@@Account_No=\"123\", Total=\"35.00\", Order_Date=\"15/02/2023\"@@Account_No=\"123\", Total=\"45.00\", Order_Date=\"19/02/2023\"@@Account_No=\"456\", Total=\"15.00\", Order_Date=\"1/01/2023\"@@Account_No=\"456\", Total=\"50.00\", Order_Date=\"25/01/2023\"@@Account_No=\"456\", Total=\"10.00\", Order_Date=\"19/02/2023\""
| makemv data delim="@@" | mvexpand data | rename data as _raw | extract
``` The above just creates the test data```

| eval month = strftime(strptime(Order_Date, "%d/%m/%Y"), "%b")
| stats sum(Total) as Total by Account_No, month
| eval {month}=Total
| fields - Total, month
| stats sum(*) as * by Account_No
| table Account_No, Ja*, Fe*,Ma*,Ap*,Ma*,Jun*, Jul*,Au*,Se*,Oc*,No*,De*&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;The last table bit at the end is so that the months are listed in the right order.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The result is:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="danspav_0-1705640073457.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/29021iEE501AFB0FF62140/image-size/large?v=v2&amp;amp;px=999" role="button" title="danspav_0-1705640073457.png" alt="danspav_0-1705640073457.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Hopefully that gets you closer to what you were looking for.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;</description>
    <pubDate>Fri, 19 Jan 2024 04:56:10 GMT</pubDate>
    <dc:creator>danspav</dc:creator>
    <dc:date>2024-01-19T04:56:10Z</dc:date>
    <item>
      <title>Total spend per field per month</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Total-spend-per-field-per-month/m-p/658111#M227329</link>
      <description>&lt;P&gt;Hi All&lt;/P&gt;&lt;P&gt;i am struggling with a query and appreciate some help please&lt;/P&gt;&lt;P&gt;i received the data on csv file - timestamp is today&amp;nbsp;&lt;/P&gt;&lt;P&gt;i'm interested in 3 fields &lt;STRONG&gt;Account_No&lt;/STRONG&gt;&amp;nbsp;, &lt;STRONG&gt;Total&lt;/STRONG&gt; and &lt;STRONG&gt;Order_Date&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;My view looks like this:&lt;/P&gt;&lt;P&gt;Account_No&amp;nbsp; &amp;nbsp; &amp;nbsp; Total&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Order_Date&lt;/P&gt;&lt;P&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 15.00&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1/01/2023&lt;/P&gt;&lt;P&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 35.00&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 15/02/2023&lt;/P&gt;&lt;P&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 45.00&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 19/02/2023&lt;/P&gt;&lt;P&gt;456&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 15.00&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1/01/2023&lt;/P&gt;&lt;P&gt;456&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 50.00&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 25/01/2023&lt;/P&gt;&lt;P&gt;456&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;10.00&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 19/02/2023&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd like a view like this&lt;/P&gt;&lt;P&gt;&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; Account_No&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Jan&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Feb&lt;/P&gt;&lt;P&gt;Total Sum&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;123&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; 15.00&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 80.00&lt;/P&gt;&lt;P&gt;&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; &amp;nbsp;456&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;65.00&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10.00&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My main issue is using the eval to change the date format that appears in the csv file from 01/01/2023 to read January 2023 or even just January will probably do for this exercise.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've come up with this so far&lt;/P&gt;&lt;P&gt;| eval Order_Date = replace(Order_Date,"01", "January") but firstly i see 06/January/2023 and not just January&amp;nbsp;&lt;/P&gt;&lt;P&gt;my other issue is that if any other month has 01 in it (for example 01/07/2023 it appears like this January/07/2023)&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;Also i started looking at stats list command to group all Account_Nos together&amp;nbsp;&lt;/P&gt;&lt;P&gt;main search.....&lt;BR /&gt;| fields Order_Date Account_No Total&lt;BR /&gt;| stats list(Total) as Total by Account_No&lt;/P&gt;&lt;P&gt;i am unable to figure out how to get the subtotals for each Account_No&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any pointers would be appreciated&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&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;&amp;nbsp;&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Sep 2023 12:03:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Total-spend-per-field-per-month/m-p/658111#M227329</guid>
      <dc:creator>PaulaCom</dc:creator>
      <dc:date>2023-09-20T12:03:09Z</dc:date>
    </item>
    <item>
      <title>Re: Total spend per field per month</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Total-spend-per-field-per-month/m-p/674784#M230974</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/258512"&gt;@PaulaCom&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;Here's a way to convert your date to "Jan", "Feb" etc:&lt;BR /&gt;strftime(date_field, format) &lt;A href="https://docs.splunk.com/Documentation/SCS/current/SearchReference/DateandTimeFunctions#strftime.28.26lt.3Btime.26gt.3B.2C.26lt.3Bformat.26gt.3B.29" target="_self"&gt;see docs&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;We can use the field Order_Date like this:&lt;BR /&gt;eval month&amp;nbsp;= strftime(strptime(Order_Date, "%d/%m/%Y"), "%b")&lt;BR /&gt;&lt;BR /&gt;That adds another step of converting the date to a unix timestamp, then converting that timestamp to the Month in english.&lt;BR /&gt;&lt;BR /&gt;Now that we have the month, we can make it a field by using special curly brackets:&lt;BR /&gt;&lt;BR /&gt;| eval {month} = Total&lt;BR /&gt;&lt;BR /&gt;That will create a field called "Jan" or "Feb" with the value of the total for sales.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Here's the Search all together:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;|makeresults | eval data="Account_No=\"123\", Total=\"15.00\", Order_Date=\"1/01/2023\"@@Account_No=\"123\", Total=\"35.00\", Order_Date=\"15/02/2023\"@@Account_No=\"123\", Total=\"45.00\", Order_Date=\"19/02/2023\"@@Account_No=\"456\", Total=\"15.00\", Order_Date=\"1/01/2023\"@@Account_No=\"456\", Total=\"50.00\", Order_Date=\"25/01/2023\"@@Account_No=\"456\", Total=\"10.00\", Order_Date=\"19/02/2023\""
| makemv data delim="@@" | mvexpand data | rename data as _raw | extract
``` The above just creates the test data```

| eval month = strftime(strptime(Order_Date, "%d/%m/%Y"), "%b")
| stats sum(Total) as Total by Account_No, month
| eval {month}=Total
| fields - Total, month
| stats sum(*) as * by Account_No
| table Account_No, Ja*, Fe*,Ma*,Ap*,Ma*,Jun*, Jul*,Au*,Se*,Oc*,No*,De*&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;The last table bit at the end is so that the months are listed in the right order.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The result is:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="danspav_0-1705640073457.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/29021iEE501AFB0FF62140/image-size/large?v=v2&amp;amp;px=999" role="button" title="danspav_0-1705640073457.png" alt="danspav_0-1705640073457.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Hopefully that gets you closer to what you were looking for.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2024 04:56:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Total-spend-per-field-per-month/m-p/674784#M230974</guid>
      <dc:creator>danspav</dc:creator>
      <dc:date>2024-01-19T04:56:10Z</dc:date>
    </item>
  </channel>
</rss>

