<?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 Report with percentages and counts per month in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Report-with-percentages-and-counts-per-month/m-p/529637#M149599</link>
    <description>&lt;P&gt;I did a search of the last 3 months on fields A = "xxx" and B = "yyy" and it has to return me 2 other fields, C and D, which contain dates.&lt;BR /&gt;I would like to make a total count (total_count) on field C divided by month.&lt;BR /&gt;Now another filter where the difference (diff_day) between the 2 dates, C and D, is less than 45 days and count how many events there are (count_event) always divided by month and finally find the percentage for each month.&lt;BR /&gt;the table must have me:&lt;BR /&gt;total_count per month,&lt;BR /&gt;count_event per month&lt;BR /&gt;count_event / total_count ie the percentage for each month.&lt;/P&gt;&lt;P&gt;My query:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;index="04_analisi"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;| where CANALE="DIRECT"&amp;nbsp; AND TIPO="ATTIVE"&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;|dedup LINK,ID&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;|eventstats count(DATA_OUT) AS total_count&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;|sort DATA_OUT&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;|eval dataout=strptime(DATA_OUT,"%Y-%m-%d")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;| eval datakpi=strptime(DATA_KPI,"%Y-%m-%d")&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;| eval diff_day=round((datakpi - dataout)/86400,0)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;| where diff_day &amp;lt;= 45&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;|eventstats count(DATA_OUT) AS count_event&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;|eval perc=round((count_event/total_count)*100,2)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;|eval Month=strftime(strptime(DATA_OUT,"%Y/%m/%d %H:%M"),"%b")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;| timechart span=1mon count(DATA_OUT)&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have tried with timechart but it is not what I want.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any suggestions?&lt;BR /&gt;I'm trying them all, reading the various questions and answers here on the community.&lt;BR /&gt;I would like to try to better understand where I am wrong.&lt;BR /&gt;Tks&lt;BR /&gt;Bye&lt;BR /&gt;Antonio&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 16 Nov 2020 21:35:40 GMT</pubDate>
    <dc:creator>antonio147</dc:creator>
    <dc:date>2020-11-16T21:35:40Z</dc:date>
    <item>
      <title>Report with percentages and counts per month</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Report-with-percentages-and-counts-per-month/m-p/529637#M149599</link>
      <description>&lt;P&gt;I did a search of the last 3 months on fields A = "xxx" and B = "yyy" and it has to return me 2 other fields, C and D, which contain dates.&lt;BR /&gt;I would like to make a total count (total_count) on field C divided by month.&lt;BR /&gt;Now another filter where the difference (diff_day) between the 2 dates, C and D, is less than 45 days and count how many events there are (count_event) always divided by month and finally find the percentage for each month.&lt;BR /&gt;the table must have me:&lt;BR /&gt;total_count per month,&lt;BR /&gt;count_event per month&lt;BR /&gt;count_event / total_count ie the percentage for each month.&lt;/P&gt;&lt;P&gt;My query:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;index="04_analisi"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;| where CANALE="DIRECT"&amp;nbsp; AND TIPO="ATTIVE"&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;|dedup LINK,ID&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;|eventstats count(DATA_OUT) AS total_count&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;|sort DATA_OUT&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;|eval dataout=strptime(DATA_OUT,"%Y-%m-%d")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;| eval datakpi=strptime(DATA_KPI,"%Y-%m-%d")&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;| eval diff_day=round((datakpi - dataout)/86400,0)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;| where diff_day &amp;lt;= 45&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;|eventstats count(DATA_OUT) AS count_event&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;|eval perc=round((count_event/total_count)*100,2)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;|eval Month=strftime(strptime(DATA_OUT,"%Y/%m/%d %H:%M"),"%b")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;| timechart span=1mon count(DATA_OUT)&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have tried with timechart but it is not what I want.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any suggestions?&lt;BR /&gt;I'm trying them all, reading the various questions and answers here on the community.&lt;BR /&gt;I would like to try to better understand where I am wrong.&lt;BR /&gt;Tks&lt;BR /&gt;Bye&lt;BR /&gt;Antonio&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Nov 2020 21:35:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Report-with-percentages-and-counts-per-month/m-p/529637#M149599</guid>
      <dc:creator>antonio147</dc:creator>
      <dc:date>2020-11-16T21:35:40Z</dc:date>
    </item>
    <item>
      <title>Re: Report with percentages and counts per month</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Report-with-percentages-and-counts-per-month/m-p/529855#M149679</link>
      <description>&lt;P&gt;Do you have a few lines worth of the original data you can provide?&amp;nbsp; I'm having a hard time envisioning what it is we're doing.&amp;nbsp;&lt;/P&gt;&lt;P&gt;It might also help if you could rephrase what it is you want. You've told us in the beginning how it is you expect to calculate what it is, but not ... not what it actually is.&amp;nbsp; Is it calculating the percentage of KPIs "complete" within 45 days of first being noted?&lt;/P&gt;&lt;P&gt;Lastly, just on a whim, I notice you created a field called `Month` but then didn't use it to split your timechart by. I don't think this will help you, but try changing your last line to&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| timechart count(DATA_OUT) BY Month&lt;/LI-CODE&gt;&lt;P&gt;You probably already tried that one, and it'll be similar to the thing you already have written. But I figured, it is worth a shot just in case it's that tiny change makes it all better for you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyway, sample data please?&lt;/P&gt;&lt;P&gt;Thanks and happy Splunking,&lt;/P&gt;&lt;P&gt;Rich&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2020 03:28:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Report-with-percentages-and-counts-per-month/m-p/529855#M149679</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2020-11-18T03:28:27Z</dc:date>
    </item>
    <item>
      <title>Re: Report with percentages and counts per month</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Report-with-percentages-and-counts-per-month/m-p/529860#M149681</link>
      <description>&lt;P&gt;Hi Rich,&lt;BR /&gt;Thanks for the reply.&lt;BR /&gt;You're right, I asked the question but I didn't say what I expect.&lt;BR /&gt;I have already tried to use: | timechart count (DATA_OUT) BY Month but the result is always the same it calculates the count divided by month but only of the events returned at the end of the query.&lt;/P&gt;&lt;P&gt;Here are the data:&lt;/P&gt;&lt;P&gt;file _raw: &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;ID &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;LINK &amp;nbsp; CANALE TIPO &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;DATA_OUT &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;DATA_KPI&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;…………… &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;1cond &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;2cond&lt;BR /&gt;——————-----------------————————————————————————&lt;/P&gt;&lt;P class="lia-align-justify"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&lt;/SPAN&gt;1 &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;123 &amp;nbsp; &amp;nbsp; direct &amp;nbsp; &amp;nbsp; &amp;nbsp;attive &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;10/08/2020 &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;21/09/2020&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;………….&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;(YES) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(YES)&lt;/P&gt;&lt;P class="lia-align-justify"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&lt;/SPAN&gt;2&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;100 &amp;nbsp; &amp;nbsp; &amp;nbsp;indirect &amp;nbsp;passive &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;15/08/2020 &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;24/08/2020 &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;……………&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;(NO) &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;(YES)&lt;/P&gt;&lt;P class="lia-align-justify"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;3&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;213 &amp;nbsp; &amp;nbsp; &amp;nbsp;direct &amp;nbsp; &amp;nbsp; attive &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;11/08/2020 &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 11&lt;/SPAN&gt;/09/2020&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;…………. &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;(YES) &amp;nbsp; &amp;nbsp; &amp;nbsp;(YES)&lt;/P&gt;&lt;P class="lia-align-justify"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;4&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;333 &amp;nbsp; &amp;nbsp;compete natural&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;25/09/2020 &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;/SPAN&gt;6/11/2020 &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;…………… &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;(NO) &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;(NO)&lt;/P&gt;&lt;P class="lia-align-justify"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;5&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;150 &amp;nbsp; &amp;nbsp; &amp;nbsp;external &amp;nbsp;verify&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;01/10/2020 &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;24/10/2020 &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;……………&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;(NO) &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;(YES)&lt;/P&gt;&lt;P class="lia-align-justify"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;6&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;223 &amp;nbsp; &amp;nbsp; &amp;nbsp; direct &amp;nbsp; &amp;nbsp;attive &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;07/09/2020 &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;/SPAN&gt;9/10/2020&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;…………. &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;(YES) &amp;nbsp; &amp;nbsp; (YES)&lt;/P&gt;&lt;P class="lia-align-justify"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;7&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;224 &amp;nbsp; &amp;nbsp; &amp;nbsp; direct &amp;nbsp; &amp;nbsp;attive &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;13/10/2020 &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 30&lt;/SPAN&gt;/11/2020&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;…………. &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;(YES) &amp;nbsp; &amp;nbsp; (NO)&lt;/P&gt;&lt;P class="lia-align-justify"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;8&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;122 indirect passive &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;15/08/2020 &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;24/10/2020 &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;…………… &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;(NO) &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;(NO)&lt;/P&gt;&lt;P class="lia-align-justify"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;9&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;216 direct attive &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01&lt;/SPAN&gt;/09/2020 &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;18/11/2020&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;…………. &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;(YES) &amp;nbsp; &amp;nbsp; &amp;nbsp;(NO)&lt;/P&gt;&lt;P class="lia-align-justify"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;10&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;217 direct attive &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;01/11/2020 &lt;SPAN class="Apple-converted-space"&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;null&lt;/SPAN&gt;&lt;SPAN class="Apple-converted-space"&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; &lt;/SPAN&gt;………….&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;(YES) &amp;nbsp; &amp;nbsp; (NO)&lt;/P&gt;&lt;P class="lia-align-justify"&gt;if the first condition is satisfied, total_count increase&lt;BR /&gt;if the first and second conditions are satisfied, count_event increment&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;RESULT &lt;SPAN&gt;1cond:&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;| where CANALE="DIRECT"&amp;nbsp; AND TIPO="ATTIVE" &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;total_count by month&lt;/P&gt;&lt;P&gt;Aug &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;2&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;(ID: 1,3)&lt;/P&gt;&lt;P&gt;Sep 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (ID: 6,9)&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Oct 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(ID: 7 &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;)&lt;/P&gt;&lt;P&gt;Nov 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (ID: 10 )&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-converted-space"&gt;Now I check how many of all these have a difference of 45 days between DATA_KPI and DATA_OUT:&lt;BR /&gt;I want the result to be:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;RESULT &lt;SPAN&gt;&amp;nbsp; &amp;nbsp;2cond:&amp;nbsp;| where diff_day &amp;lt;= 45 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;count_event by month&lt;/P&gt;&lt;P&gt;Aug 2&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;(ID: 1,3)&lt;/P&gt;&lt;P&gt;Sep 1&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;(ID: 6)&lt;/P&gt;&lt;P&gt;Oct 0 &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Nov 0&lt;/P&gt;&lt;P&gt;Now the percentage for each of them (consider that the values are not that low)&lt;/P&gt;&lt;P&gt;My final table count by month: &amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;SPAN&gt;perc=round((count_event/total_count)*100,2)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Mount &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; total_count &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;count_event &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;percent&lt;/P&gt;&lt;P&gt;————————————————————————&lt;/P&gt;&lt;P&gt;Aug &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &lt;SPAN class="Apple-converted-space"&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;&lt;/SPAN&gt;100%&lt;/P&gt;&lt;P&gt;Sep &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &lt;SPAN class="Apple-converted-space"&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;&lt;/SPAN&gt;50%&lt;/P&gt;&lt;P&gt;Oct &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 &lt;SPAN class="Apple-converted-space"&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;&lt;/SPAN&gt;0%&lt;/P&gt;&lt;P&gt;Nov &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 &lt;SPAN class="Apple-converted-space"&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;&lt;/SPAN&gt;0%&lt;/P&gt;&lt;P&gt;so it sure is clearer &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;Then I think in the end it is not difficult to add all the total_count and the count_even to also have a general count.&lt;BR /&gt;Thanks again&lt;BR /&gt;Bye&lt;BR /&gt;Antonio&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2020 05:57:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Report-with-percentages-and-counts-per-month/m-p/529860#M149681</guid>
      <dc:creator>antonio147</dc:creator>
      <dc:date>2020-11-18T05:57:37Z</dc:date>
    </item>
    <item>
      <title>Re: Report with percentages and counts per month</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Report-with-percentages-and-counts-per-month/m-p/529954#M149710</link>
      <description>&lt;P&gt;Excellent, with that data, I ... well, we'll see if this is *right* or not, but at least it's gonna be way closer.&lt;/P&gt;&lt;P&gt;I converted your data into a CSV file and uploaded to my system so I have a thing I can use with `| inputlookup` (I'll paste all code later, after the screenshots so you can copy/paste it if needed).&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Richfez_0-1605714588083.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/11964i89D8E7E42E171020/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Richfez_0-1605714588083.png" alt="Richfez_0-1605714588083.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I had to fiddle a little with the date formats (not worth my effort to figure why), but then I got the new fields created.&amp;nbsp; In addition, I assigned the field `_time` to dataout, perhaps that should be set to datakpi instead.&amp;nbsp; Either way, that's left as an exercise for the reader.&amp;nbsp;&amp;nbsp; Also my fields are differently named, I'm sure you'll figure that part out and correct as you want.&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;If you are color blind, I can do something different here but hopefully it'll come across OK.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Richfez_1-1605714764627.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/11965i0F67677E5E735201/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Richfez_1-1605714764627.png" alt="Richfez_1-1605714764627.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;And, now that we have told Splunk what field to use as _time, things like timechart will work.&lt;/P&gt;&lt;P&gt;And in timechart, you can actually do some pretty complex conditional expressions if you want.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Richfez_2-1605714896724.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/11966iE48E8090EF43C092/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Richfez_2-1605714896724.png" alt="Richfez_2-1605714896724.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Much of this can also be done by replacing the `timechart span=1mon` command with the pair of commands `bin span=1mon _time` and a big stats like the timechart, split by _time.&lt;/P&gt;&lt;P&gt;Stats is more versatile, but I think either works fine in this case.&amp;nbsp; Stats may also be *slightly* better performing if you are in a large Splunk distributed system, but I doubt the difference is large.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Richfez_3-1605715096231.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/11967iFE67A74ACCB46B50/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Richfez_3-1605715096231.png" alt="Richfez_3-1605715096231.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;And as mentioned, if you want to move that complexity out of the timechart/stats command and into its own eval, it would look like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Richfez_4-1605715278140.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/11968i0F7E4EF604963090/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Richfez_4-1605715278140.png" alt="Richfez_4-1605715278140.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;You can do a similar thing with the timechart one too.&lt;/P&gt;&lt;P&gt;As promised, the actual code, stats one with separate evals first because that's what's on my screen right now and I'm lazy.&amp;nbsp; KEEP IN MIND that you'll have to swap out my `| inputlookup lookup_KPI.csv` command for your own search, and fix up those dates again back to the right way.&amp;nbsp; Also change field names in the "AS blah" sections.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup lookup_KPI.csv
| eval dataout = strptime(DATA_OUT,"%d/%m/%Y")
| eval datakpi = strptime(DATA_KPI,"%d/%m/%Y")
| eval diff_day = round((datakpi - dataout)/86400,0)
| eval _time = dataout
| eval sum_for_direct_attive = if(CANALE=="direct" AND TIPO=="attive", 1, 0)
| eval sum_for_diff_day_over_45 = if(diff_day &amp;lt;= 45, 1, 0)
| bin span=1mon _time
| stats sum(sum_for_direct_attive) AS direct_attive sum(sum_for_diff_day_over_45) AS diff_day_over_45 BY _time
| eval perc = round((direct_attive/diff_day_over_45)*100,2)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp; Stats one with sum(eval...) syntax:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup lookup_KPI.csv
| eval dataout = strptime(DATA_OUT,"%d/%m/%Y")
| eval datakpi = strptime(DATA_KPI,"%d/%m/%Y")
| eval diff_day = round((datakpi - dataout)/86400,0)
| eval _time = dataout
| bin span=1mon _time
| stats sum(eval(if(CANALE=="direct" AND TIPO=="attive", 1, 0))) AS direct_attive sum(eval(if(diff_day &amp;lt;= 45, 1, 0))) AS diff_day_over_45 BY _time
| eval perc = round((direct_attive/diff_day_over_45)*100,2)&lt;/LI-CODE&gt;&lt;P&gt;And the timechart one, just for good measure.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup lookup_KPI.csv
| eval dataout = strptime(DATA_OUT,"%d/%m/%Y")
| eval datakpi = strptime(DATA_KPI,"%d/%m/%Y")
| eval diff_day = round((datakpi - dataout)/86400,0)
| eval _time = dataout
| timechart span=1mon sum(eval(if(CANALE=="direct" AND TIPO=="attive", 1, 0))) AS direct_attive sum(eval(if(diff_day &amp;lt;= 45, 1, 0))) AS diff_day_over_45
| eval perc = round((direct_attive/diff_day_over_45)*100,2)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this gets you the answers you need!&lt;/P&gt;&lt;P&gt;Happy Splunking,&lt;/P&gt;&lt;P&gt;Rich&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2020 16:06:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Report-with-percentages-and-counts-per-month/m-p/529954#M149710</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2020-11-18T16:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: Report with percentages and counts per month</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Report-with-percentages-and-counts-per-month/m-p/530000#M149725</link>
      <description>&lt;P&gt;Hi Rich,&lt;BR /&gt;you don't know how grateful I am, not so much for the code,, which works great, but above all because you explained to me many things that were not clear to me.&lt;BR /&gt;Were you able to make me understand how to set up a search in splunk and understand how to use commands and functions together.&lt;BR /&gt;I answer your words, let's start with ... luckily I'm not color blind &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; so I understand all your steps well.&lt;/P&gt;&lt;P&gt;I have fixed some things in the code that I may not have explained well; the condition &amp;lt;= 45 must be applied only to those events that satisfy the first condition, i.e. I have to count:&lt;/P&gt;&lt;P&gt;1) how many are sum_for_direct_active (and here and OK)&lt;BR /&gt;2) of these sum_for_direct_active, how many are &amp;lt;= 45 ??&lt;/P&gt;&lt;P&gt;then your line:&lt;BR /&gt;| eval sum_for_diff_day_over_45 = if (diff_day &amp;lt;= 45, 1, 0)&lt;/P&gt;&lt;P&gt;I replaced it with:&lt;BR /&gt;| eval sum_for_diff_day_over_45 = if (CHANNEL == "direct" AND TYPE == "active" AND diff_day &amp;lt;= 45, 1, 0)&lt;/P&gt;&lt;P&gt;and I got the correct value.&lt;/P&gt;&lt;P&gt;Also I changed:&lt;BR /&gt;| eval perc = round ((direct_active / diff_day_over_45) * 100,2)&lt;/P&gt;&lt;P&gt;with&lt;BR /&gt;| eval perc = round ((diff_day_over_45 / direct_attive) * 100,2)&lt;/P&gt;&lt;P&gt;for which&lt;BR /&gt;| eval _time = dataout IS GREAT !!&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I took the stats instead of the timechart as a suggestion and also used&lt;BR /&gt;eval sum_for_diff_day_over_45 = if (CHANNEL == "direct" AND TYPE == "active" AND diff_day &amp;lt;= 45, 1, 0)&lt;/P&gt;&lt;P&gt;which seems to me a cleaner style instead of&lt;/P&gt;&lt;P&gt;| stats sum (eval (if (CHANNEL == "direct" AND TYPE == "active", 1, 0))) AS direct_attive sum (eval (if (diff_day &amp;lt;= 45, 1, 0))) AS diff_day_over_45 BY _time&lt;/P&gt;&lt;P&gt;I see it more complicated to read and understand.&lt;BR /&gt;YOUR SUGGESTION WAS GREAT !!&lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thank you so much you made me understand a lot.&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;&lt;P&gt;There are 2 things I want to ask you:&lt;/P&gt;&lt;P&gt;1) Why did you put the sum after the stats?&lt;BR /&gt;| stats sum (sum_for_direct_attive) AS direct_attive sum (sum_for_diff_day_over_45) AS diff_day_over_45 BY _time&lt;/P&gt;&lt;P&gt;it would never have occurred to me to put it on;&lt;BR /&gt;I haven't tried without, tomorrow I'll try,&lt;BR /&gt;but I don't know why.&lt;/P&gt;&lt;P&gt;2) I realized that in my splunk despite having set 3 months to Latest, there are, in the DATA_OUT field, dates that refer to 2018, so events from the months of 2018 return to me.&lt;BR /&gt;I would only like the last 3 months back, so from August.&lt;/P&gt;&lt;P&gt;I also inserted in the first condition&amp;gt; = 2020-08- * but I don't like it very much.&lt;/P&gt;&lt;P&gt;| eval sum_for_direct_attive = if (CHANNEL == "direct" AND TYPE == "active" AND DATA_OUT&amp;gt; = "2020-08- *", 1, 0)&lt;/P&gt;&lt;P&gt;Is there a better way to drop the months back and only take the last 3?&lt;/P&gt;&lt;P&gt;You have really given me an edge in understanding SPlunk and I will be truly grateful to you.&lt;BR /&gt;Thank you so much&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;&lt;P&gt;You are a great Rich !!!&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":flexed_biceps:"&gt;💪&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":top_arrow:"&gt;🔝&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":top_arrow:"&gt;🔝&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":top_arrow:"&gt;🔝&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":top_arrow:"&gt;🔝&lt;/span&gt;&lt;/P&gt;&lt;P&gt;See you soon&lt;BR /&gt;Bye&lt;BR /&gt;Antonio&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2020 21:24:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Report-with-percentages-and-counts-per-month/m-p/530000#M149725</guid>
      <dc:creator>antonio147</dc:creator>
      <dc:date>2020-11-18T21:24:14Z</dc:date>
    </item>
    <item>
      <title>Re: Report with percentages and counts per month</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Report-with-percentages-and-counts-per-month/m-p/530006#M149728</link>
      <description>&lt;P&gt;Aww, thank you.&amp;nbsp; I'm glad you found it useful.&lt;/P&gt;&lt;P&gt;Your changes look perfect to me - and I had to laugh, I usually write when I do division to come up with percentages that I *always* do the math backwards and that you'll probably have to fix it.&amp;nbsp; Glad you noticed without me telling you to.&lt;/P&gt;&lt;P&gt;For the sum in the stats - Well, the calculations were going to be harder to do an actual count, or maybe not harder, but would look less clear?&amp;nbsp; Counting things is really just summing up "1" each time you count an item, right?&amp;nbsp; So I've gotten used to, whenever I'm dealing with a *conditional* count to use the sum of 1 when it matches, 0 when it doesn't.&amp;nbsp; It just seems easier to understand.&lt;/P&gt;&lt;P&gt;(And obviously, for simple cases where you just want a count, you just `stats count by _time` or whatever, plain old "count" works fantastically well in that case.)&lt;/P&gt;&lt;P&gt;Excellent work on fixing me having forgotten your 45 day limit.&amp;nbsp; That's probably why my numbers didn't match yours.&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;For your last question on dates and old data&lt;/STRONG&gt;, I guess the question here really is, how is this data being ingested?&amp;nbsp; In my mind, the rightest answer to this problem is to re-ingest the data (I assume it's not huge and it's in a text file somewhere?) and when you set up that input make sure it is reading the dates correctly, and using the right date field as the date to use for _time.&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can see I hacked in a way to make it work, assigning _time to one of the interpreted date fields using eval, but it would be better to just have that step done on the input itself.&lt;/P&gt;&lt;P&gt;(&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.1.0/Data/Configuretimestamprecognition" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/8.1.0/Data/Configuretimestamprecognition&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;If you did that, then your time picker would work.&amp;nbsp; You could just pick "last 3 months" from the time picker in the upper right, and it'd filter everything correctly.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;But, since we don't have that set up yet&lt;/STRONG&gt;, I did a thing:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval _time = dataout
| eval oldest = relative_time(now(), "-3mon@mon"), newest = relative_time(now(), "@mon")
| where _time &amp;gt; oldest AND _time &amp;lt; newest
| bin span=1mon _time&lt;/LI-CODE&gt;&lt;P&gt;I didn't include the whole mess, just included the two lines you can add (and a line before and after it so you can see where it fits - after we eval a _time, and before we do the bin on _time.).&lt;/P&gt;&lt;P&gt;What I do there is create two fields using a function in splunk called "relative_time".&amp;nbsp; Here's how relative time works and in there is other links to various other things that may help understanding it.&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/SCS/current/Search/Specifyrelativetim" target="_blank"&gt;https://docs.splunk.com/Documentation/SCS/current/Search/Specifyrelativetim&lt;/A&gt;e&lt;/P&gt;&lt;P&gt;The first field is the oldest records we want to keep, so I set it to "-3 months ago (e.g. "before now()"), snapped to the beginning of that month" with the setting "-3mon@mon".&amp;nbsp;&amp;nbsp; So run here in the middle of November 18th, it'll go back three months to August 18th then back to the beginning of that month, August 1.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also snapped the newest records we want to the beginning of this month, Nov 1.&lt;/P&gt;&lt;P&gt;You actually probably don't want any snapping, now that I've said all that. I think you probably want those to read "-3mon" and not even create the newest value at all.&amp;nbsp; Then obviously if that's the case your where gets simpler.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So if you don't want the snapping, try:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval _time = dataout
| eval oldest = relative_time(now(), "-3mon")
| where _time &amp;gt; oldest 
| bin span=1mon _time&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In any case, I think you know where you'll have to look (the input and whatnot) for fixing this "generically" so the time picker works, and that even without this, you should have you a reasonable workaround.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me know if that all works!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2020 22:33:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Report-with-percentages-and-counts-per-month/m-p/530006#M149728</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2020-11-18T22:33:16Z</dc:date>
    </item>
    <item>
      <title>Re: Report with percentages and counts per month</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Report-with-percentages-and-counts-per-month/m-p/530030#M149740</link>
      <description>&lt;P&gt;But why do you calculate the percentage in reverse?&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt;&lt;BR /&gt;I laughed too on this occasion&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks for the explanations, always very useful for beginners.&lt;BR /&gt;the "sum" I meant is this:&lt;/P&gt;&lt;P&gt;| stats &lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;SUM&lt;/FONT&gt;&lt;/STRONG&gt; (sum_for_direct_attive) AS direct_attive &lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;SUM&lt;/FONT&gt;&lt;/STRONG&gt; (sum_for_diff_day_over_45) AS diff_day_over_45 BY _time&lt;BR /&gt;In this context, I don't understand what adds up&lt;/P&gt;&lt;P&gt;while adding 1 if the condition is satisfied and zero when it is not, it seems to me an excellent solution to be sure of having the correct sum.&lt;/P&gt;&lt;P&gt;After I answered you last night, I was on my way to bed and something similar to the one you suggested for the past 3 months occurred to me.&lt;BR /&gt;Use relative_time (now (), "-3mon @ mon") or latest to go back 3 months.&lt;/P&gt;&lt;P&gt;The data on splunk is millions, I can't import again, mainly because I don't have admin privileges, I'm just a simple "Power"&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;BR /&gt;They are imported correctly, the DATA_OUT field has a date that refers to an action performed on that date and remains so until an action is performed again (date when the status changed).&lt;BR /&gt;For this reason, also on November 18th in this field I can find the date of February 8th 2018.&lt;BR /&gt;However, this value does not interest me as it is too far back in time.&lt;BR /&gt;Now I just have to figure out if relative_time (now (), "-3mon @ mon") takes me to August 1st or August 19th (if I run the command today).&lt;BR /&gt;Anyway, I don't think it's a big deal to fix this.&lt;/P&gt;&lt;P&gt;Thanks again for your precious explanations, it is a pleasure to talk to you, I hope there is still an opportunity to do so.&lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;BR /&gt;See you soon&lt;BR /&gt;Bye&lt;BR /&gt;Antonio&lt;/P&gt;</description>
      <pubDate>Thu, 19 Nov 2020 07:25:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Report-with-percentages-and-counts-per-month/m-p/530030#M149740</guid>
      <dc:creator>antonio147</dc:creator>
      <dc:date>2020-11-19T07:25:19Z</dc:date>
    </item>
    <item>
      <title>Re: Report with percentages and counts per month</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Report-with-percentages-and-counts-per-month/m-p/530042#M149746</link>
      <description>&lt;P&gt;UPDATE:&lt;BR /&gt;I inserted these 2 lines at the top after the index:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;| eval oldest = relative_time (now (), "&lt;FONT color="#FF0000"&gt;-3mon&lt;/FONT&gt;")&lt;BR /&gt;| eval threemonthsago= strftime (relative_time (oldest, "@mon"), "% Y-% m-% d")&lt;BR /&gt;| where DATA_OUT&amp;gt; = threemonthsago&lt;/P&gt;&lt;P&gt;in this way I always take the previous 3 months starting from the first of each month.&lt;BR /&gt;If you want I can change the search to 4,5,6 .... months back by changing only the &lt;FONT color="#FF0000"&gt;-3mon&lt;/FONT&gt; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;very good solution !!!&lt;BR /&gt;Thanks to your suggestions&lt;/P&gt;</description>
      <pubDate>Thu, 19 Nov 2020 07:38:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Report-with-percentages-and-counts-per-month/m-p/530042#M149746</guid>
      <dc:creator>antonio147</dc:creator>
      <dc:date>2020-11-19T07:38:18Z</dc:date>
    </item>
    <item>
      <title>Re: Report with percentages and counts per month</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Report-with-percentages-and-counts-per-month/m-p/530115#M149778</link>
      <description>&lt;P&gt;Ah, those sums.&lt;/P&gt;&lt;P&gt;I'm not quite sure if you then answered your own question?&lt;/P&gt;&lt;P&gt;In any case, leave off the `| stats ... ` and everything after it, and you'll see that the field 'sum_for_direct_attive` and that other field are both either 0 or 1 depending on the eval we did earlier.&amp;nbsp; Which that eval is really just a replacement for the previous examples inline evals in the stats command itself.&lt;/P&gt;&lt;P&gt;So, since we've created those fields before the stats command, we can just sum up the 1's and 0's of those events appropriately.&lt;/P&gt;&lt;P&gt;inline evals in stats can be great, but sometimes they just make the stats command really complex looking, so sometimes it's better to just split those out into their own little bits of logic so they're easier to understand and work on.&lt;/P&gt;&lt;P&gt;And in case you didn't figure it out, "-3mon@mon" would go back to August 1st.&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can mix and match those too.&amp;nbsp; "-90d" goes back 90 days from this time right now, but "-90d@d" goes back to the midnight that happened just before day 90 ago.&lt;/P&gt;&lt;P&gt;"-3mon@d" goes back three months, then backs up until midnight of that day to include the entire day from 3 months ago, instead of only the partial day.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Nov 2020 17:18:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Report-with-percentages-and-counts-per-month/m-p/530115#M149778</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2020-11-19T17:18:54Z</dc:date>
    </item>
    <item>
      <title>Re: Report with percentages and counts per month</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Report-with-percentages-and-counts-per-month/m-p/530126#M149783</link>
      <description>&lt;P&gt;Hi Rich,&lt;BR /&gt;now it's clear !!!&lt;BR /&gt;Eval generates a new field with the elements 0 and 1 depending on the true or false condition.&lt;BR /&gt;The SUM after, sums all the elements of the created field.&lt;BR /&gt;I had confused "sum" in the variable name,&lt;/P&gt;&lt;P&gt;The -3mon @ mon in my query took dates from 2020-08-18, for this I had to add:&lt;BR /&gt;| eval threemonthsago = strftime (relative_time (oldest, "@mon"), "% Y-% m-% d")&lt;/P&gt;&lt;P&gt;But now a strange thing happens to me (surely I'm wrong :))&lt;BR /&gt;if I put -9mon @ mon it takes into account the dates of February (ok, correct) but it goes until August and not until November as I expected.&lt;BR /&gt;IMPORTANT: at the top right I chose "latest 3 months.&lt;/P&gt;&lt;P&gt;If instead I write -3mon @ mon always with latest 3 months, it returns me from August to November&lt;/P&gt;&lt;P&gt;Why??&lt;BR /&gt;Does the latest 3 m3si have anything to do with it?&lt;BR /&gt;This behavior is not clear to me.&lt;/P&gt;&lt;P&gt;Anyway, I don't want to address all my doubts in this post, otherwise I will have to pay you for the lessons you are providing &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I like to understand why things, but I certainly don't want to take advantage of your kindness and patience.&lt;BR /&gt;I still have to study a lot .......&lt;BR /&gt;You have already helped me a lot in understanding and making my query work.&lt;BR /&gt;I thank you for this&lt;/P&gt;&lt;P&gt;See you soon&lt;BR /&gt;Antonio&lt;/P&gt;</description>
      <pubDate>Thu, 19 Nov 2020 20:03:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Report-with-percentages-and-counts-per-month/m-p/530126#M149783</guid>
      <dc:creator>antonio147</dc:creator>
      <dc:date>2020-11-19T20:03:41Z</dc:date>
    </item>
  </channel>
</rss>

