<?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 create cumulative chart separated by a field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-cumulative-chart-separated-by-a-field/m-p/366527#M108121</link>
    <description>&lt;P&gt;@niketnilay thank you for your answer. I accepted the answer as solved, it did solve my answer.&lt;BR /&gt;
I am new to Splunk and I would really appreciate if you could tell me a bit about the code you wrote (the code that starts with ).&lt;BR /&gt;
In addition, is there a way to add the mentionung of every weak. now the report only shows 4 months in every year.&lt;BR /&gt;
thanks again.&lt;/P&gt;</description>
    <pubDate>Sat, 18 Mar 2017 17:50:22 GMT</pubDate>
    <dc:creator>matansocher</dc:creator>
    <dc:date>2017-03-18T17:50:22Z</dc:date>
    <item>
      <title>How to create cumulative chart separated by a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-cumulative-chart-separated-by-a-field/m-p/366520#M108114</link>
      <description>&lt;P&gt;I need to create a chart, looking like the example I added.&lt;BR /&gt;
the chart needs to show the cumulative number of tasks opened until the date, but separated by "Severity".,&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/2644i06BDECF46C72D4ED/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;the following code does give me a cumulative count by time of the tasks but not separating by the field "Severity".&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=clearquest "Root Project"=IPA_4* "Project Name"=IPA_4* ("Task Type"="Enhancement A*" OR "Task Type"=Defe* OR "Task Type"=Doc*) "Resolution"=* "Severity"=* "Task ID"=* 
| dedup "Task ID" 
| reverse
| timechart span=1w count("Task ID") AS sum_of_tasks_per_week 
| streamstats sum(sum_of_tasks_per_week) AS TI_accumulate
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/2645i3AC7BAEA7C5E36A5/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;how do I create that separation that I need like the graph I added?&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2017 16:02:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-cumulative-chart-separated-by-a-field/m-p/366520#M108114</guid>
      <dc:creator>matansocher</dc:creator>
      <dc:date>2017-03-17T16:02:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to create cumulative chart separated by a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-cumulative-chart-separated-by-a-field/m-p/366521#M108115</link>
      <description>&lt;P&gt;Add &lt;STRONG&gt;by Severity&lt;/STRONG&gt; clause to your timechart query. Also instead of performing a dedup and then count("Task ID"), you can use &lt;STRONG&gt;distinct_count()&lt;/STRONG&gt; or &lt;STRONG&gt;dc()&lt;/STRONG&gt; aggregate function.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| timechart span=1w dc("Task ID") AS sum_of_tasks_per_week by Severity
| accum S0-Critical
| accum S1-Severe
| accum "S2-Medium Impact"
| accum "S3-Low Impact"
| accum S4-Unknown 
| accum Complete
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;[UPDATED] &lt;/P&gt;

&lt;P&gt;Added query to generate accum block dynamically based on number of Severity values(example considers max 5 values).&lt;BR /&gt;
Also added accum to original query provided to consolidate both answers. &lt;/P&gt;

&lt;P&gt;There might be a neat way of performing dynamic accum without supplying the field name, but I am not aware of the same. Following is what I could come up with. If you know maximum number of fields your can write a query with &lt;STRONG&gt;transpose&lt;/STRONG&gt; and &lt;STRONG&gt;tail&lt;/STRONG&gt; to get the field names and then generate accum query block dynamically without having to know the actual field names. (Info of Max. no of fields will be required query will adjust dynamically according to no. of fields available for search duration.). Following example assumes maximum five fields.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  &amp;lt;search id="baseSeverity"&amp;gt;
    &amp;lt;query&amp;gt; index=clearquest "Root Project"=IPA_4* "Project Name"=IPA_4* ("Task Type"="Enhancement A*" OR "Task Type"=Defe* OR "Task Type"=Doc*) "Resolution"=* "Severity"=* "Task ID"=* 
| stats count by Severity&amp;lt;/query&amp;gt;
        &amp;lt;earliest&amp;gt;$selTime.earliest$&amp;lt;/earliest&amp;gt;
        &amp;lt;latest&amp;gt;$selTime.latest$&amp;lt;/latest&amp;gt;
    &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
    &amp;lt;done&amp;gt;
      &amp;lt;condition match="$job.resultCount$&amp;amp;gt;0"&amp;gt;
        &amp;lt;set token="CountofSeverity"&amp;gt;$job.resultCount$&amp;lt;/set&amp;gt;
      &amp;lt;/condition&amp;gt;
    &amp;lt;/done&amp;gt;
  &amp;lt;/search&amp;gt;
  &amp;lt;search base="baseSeverity"&amp;gt;
    &amp;lt;query&amp;gt;| transpose
    | tail 1&amp;lt;/query&amp;gt;
    &amp;lt;preview&amp;gt;
      &amp;lt;condition match="$CountofSeverity$==&amp;amp;quot;5&amp;amp;quot;"&amp;gt;
        &amp;lt;set token="queryAccumToken"&amp;gt;| accum "$result.row 1$" | accum "$result.row 2$" | accum "$result.row 3$" | accum "$result.row 4$" | accum "$result.row 5$"&amp;lt;/set&amp;gt;
      &amp;lt;/condition&amp;gt;
      &amp;lt;condition match="$CountofSeverity$==&amp;amp;quot;4&amp;amp;quot;"&amp;gt;
        &amp;lt;set token="queryAccumToken"&amp;gt;| accum "$result.row 1$" | accum "$result.row 2$" | accum "$result.row 3$" | accum "$result.row 4$"&amp;lt;/set&amp;gt;
      &amp;lt;/condition&amp;gt;
      &amp;lt;condition match="$CountofSeverity$==&amp;amp;quot;3&amp;amp;quot;"&amp;gt;
        &amp;lt;set token="queryAccumToken"&amp;gt;| accum "$result.row 1$" | accum "$result.row 2$" | accum "$result.row 3$"&amp;lt;/set&amp;gt;
      &amp;lt;/condition&amp;gt;
      &amp;lt;condition match="$CountofSeverity$==&amp;amp;quot;2&amp;amp;quot;"&amp;gt;
        &amp;lt;set token="queryAccumToken"&amp;gt;| accum "$result.row 1$" | accum "$result.row 2$"&amp;lt;/set&amp;gt;
      &amp;lt;/condition&amp;gt;
      &amp;lt;condition match="$CountofSeverity$==&amp;amp;quot;1&amp;amp;quot;"&amp;gt;
        &amp;lt;set token="queryAccumToken"&amp;gt;| accum "$result.row 1$" &amp;lt;/set&amp;gt;
      &amp;lt;/condition&amp;gt;
      &amp;lt;condition&amp;gt;
        &amp;lt;set token="queryAccumToken"&amp;gt; &amp;lt;/set&amp;gt;
      &amp;lt;/condition&amp;gt;
    &amp;lt;/preview&amp;gt;
  &amp;lt;/search&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Finally after your base search with timechart just add $queryAccumToken$&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| timechart span=1w dc("Task ID") AS sum_of_tasks_per_week by Severity $queryAccumToken$
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please let me know if this solves your issue. If it does please accept the answer.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2017 16:13:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-cumulative-chart-separated-by-a-field/m-p/366521#M108115</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-03-17T16:13:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to create cumulative chart separated by a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-cumulative-chart-separated-by-a-field/m-p/366522#M108116</link>
      <description>&lt;P&gt;thanks for the answer.&lt;BR /&gt;
that change does give me what I think I need in the statistic table, but not in the visualization tab:&lt;BR /&gt;
&lt;IMG src="http://imgur.com/a/1L60t" alt="alt text" /&gt;&lt;BR /&gt;
The chart keeps coming back to zero every weak, and I need the count to be cumulative.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2017 21:38:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-cumulative-chart-separated-by-a-field/m-p/366522#M108116</guid>
      <dc:creator>matansocher</dc:creator>
      <dc:date>2017-03-17T21:38:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to create cumulative chart separated by a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-cumulative-chart-separated-by-a-field/m-p/366523#M108117</link>
      <description>&lt;P&gt;Assuming that your records are currently just the daily statistics, try the &lt;CODE&gt;| accum&lt;/CODE&gt; command before going into the chart.  &lt;/P&gt;</description>
      <pubDate>Sat, 18 Mar 2017 03:13:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-cumulative-chart-separated-by-a-field/m-p/366523#M108117</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-03-18T03:13:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to create cumulative chart separated by a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-cumulative-chart-separated-by-a-field/m-p/366524#M108118</link>
      <description>&lt;P&gt;You will have to mention the field names generated by timechart&lt;/P&gt;

&lt;P&gt;| timechart span=1w dc("Task ID") AS sum_of_tasks_per_week by Severity&lt;BR /&gt;
| accum S0-Critical as S0-Critical&lt;BR /&gt;
| accum S1-Severe as S1-Severe&lt;BR /&gt;
| accum "S2-Medium Impact" as "S2-Medium Impact"&lt;BR /&gt;
| accum "S3-Low Impact" as "S3-Low Impact"&lt;BR /&gt;
| accum S4-Unknown as S4-Unknown &lt;BR /&gt;
| accum Complete as Complete&lt;BR /&gt;
...&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:18:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-cumulative-chart-separated-by-a-field/m-p/366524#M108118</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-09-29T13:18:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to create cumulative chart separated by a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-cumulative-chart-separated-by-a-field/m-p/366525#M108119</link>
      <description>&lt;P&gt;thank you.&lt;BR /&gt;
that gave me the result I wanted.&lt;BR /&gt;
If I had many values for the field severity, Is there a way not to write manually the values of the field?&lt;/P&gt;</description>
      <pubDate>Sat, 18 Mar 2017 11:33:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-cumulative-chart-separated-by-a-field/m-p/366525#M108119</guid>
      <dc:creator>matansocher</dc:creator>
      <dc:date>2017-03-18T11:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to create cumulative chart separated by a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-cumulative-chart-separated-by-a-field/m-p/366526#M108120</link>
      <description>&lt;P&gt;@matansocher, I have updated my answer. Please accept the answer if this solves your issue.&lt;BR /&gt;
There might be SPL command available to perform accum without having to know the field names. But I am not aware of. However, I have written a condition block which should work only if you know what will be maximum number of Severity field values (example is with 5 but you can extend for more). This will not require you to know the field names.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Mar 2017 16:44:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-cumulative-chart-separated-by-a-field/m-p/366526#M108120</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-03-18T16:44:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to create cumulative chart separated by a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-cumulative-chart-separated-by-a-field/m-p/366527#M108121</link>
      <description>&lt;P&gt;@niketnilay thank you for your answer. I accepted the answer as solved, it did solve my answer.&lt;BR /&gt;
I am new to Splunk and I would really appreciate if you could tell me a bit about the code you wrote (the code that starts with ).&lt;BR /&gt;
In addition, is there a way to add the mentionung of every weak. now the report only shows 4 months in every year.&lt;BR /&gt;
thanks again.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Mar 2017 17:50:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-cumulative-chart-separated-by-a-field/m-p/366527#M108121</guid>
      <dc:creator>matansocher</dc:creator>
      <dc:date>2017-03-18T17:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to create cumulative chart separated by a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-cumulative-chart-separated-by-a-field/m-p/366528#M108122</link>
      <description>&lt;P&gt;You are currently only voted the answers/comments. For accepting you need to click &lt;STRONG&gt;Accept&lt;/STRONG&gt; link below my answer. Only after that this question will be marked as answered.&lt;/P&gt;

&lt;P&gt;The reason for your timechart showing only 4 points for a year is because timeshart adjusts x axis for showing labels dynamically, it can not accommodate all weeks. However, you can try setting the timechart properties and rotate the x-axis label by 90 to see if it helps.&lt;/P&gt;

&lt;P&gt;As far as the code is concerned let me try to break it down a bit...&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;search id="baseSeverity"&lt;/STRONG&gt; creates a base search to be reused later in the code. It is called Post Processing in Splunk. I have called base search through &lt;STRONG&gt;search base="baseSeverity"&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;preview&lt;/STRONG&gt; and &lt;STRONG&gt;done&lt;/STRONG&gt; are search event handlers for accessing search related info and assign the same to &lt;STRONG&gt;tokens&lt;/STRONG&gt; to be used in the form.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;job.resultCount&lt;/STRONG&gt; is built-in token which contains the number if results returned by a search. In our case it is the number of &lt;STRONG&gt;Severity&lt;/STRONG&gt; values we get for specified time.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;result.&amp;lt;fieldname&amp;gt;&lt;/STRONG&gt; is another Splunk's search related token which allows you to access single value result of result from the first row(it can not read multiple row, which is the reason why I have performed &lt;STRONG&gt;tail 1&lt;/STRONG&gt; in my query with &lt;STRONG&gt;transpose&lt;/STRONG&gt;)&lt;/P&gt;

&lt;P&gt;Transpose reverses the axis for result because of which the Severity values become columns from rows and can be access through generic field names created by transpose which is &lt;STRONG&gt;"row 1", "row 2"&lt;/STRONG&gt; and so on (by default). &lt;/P&gt;

&lt;P&gt;You can try the following queries step by step to understand:&lt;/P&gt;

&lt;P&gt;Step 1&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=clearquest "Root Project"=IPA_4* "Project Name"=IPA_4* ("Task Type"="Enhancement A*" OR "Task Type"=Defe* OR "Task Type"=Doc*) "Resolution"=* "Severity"=* "Task ID"=* 
| stats count by Severity
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Step 2&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| transpose
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Step 3&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tail 1
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 18 Mar 2017 20:08:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-cumulative-chart-separated-by-a-field/m-p/366528#M108122</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-03-18T20:08:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to create cumulative chart separated by a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-cumulative-chart-separated-by-a-field/m-p/366529#M108123</link>
      <description>&lt;P&gt;when you put any code into the web interface, be sure to mark it with the code button (the one with 101 010 on it) so that the web interface will not "eat" everything that looks like html.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2017 03:11:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-cumulative-chart-separated-by-a-field/m-p/366529#M108123</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-03-20T03:11:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to create cumulative chart separated by a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-cumulative-chart-separated-by-a-field/m-p/366530#M108124</link>
      <description>&lt;P&gt;@DalJeanis, if that was for me, I have added my code to updated answer above. In my previous comment I was just dissecting some of the code blocks which are in bold font for explanation.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2017 11:51:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-cumulative-chart-separated-by-a-field/m-p/366530#M108124</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-03-20T11:51:57Z</dc:date>
    </item>
  </channel>
</rss>

