<?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 do I create a piechart visualization with the count of two field values and the sum of both displayed? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-piechart-visualization-with-the-count-of-two/m-p/360464#M106539</link>
    <description>&lt;P&gt;@Anonymous&lt;BR /&gt;
Hi Giuseppe- Thank you . this works.&lt;BR /&gt;
However, If I am to search two words instead of just ab, how would I tweak the string.&lt;BR /&gt;
Example : I want (ab AND null1) to be counted and (pq AND null2) to be counted.&lt;BR /&gt;
Is the following line correct (syntax wise) ?&lt;/P&gt;

&lt;P&gt;| eval word=case(like(_raw,"%ab%") AND like(_raw,"%null1%),"ab",like(_raw,"%pq%") AND like(_raw,"%null2%),"pq") &lt;BR /&gt;
| stats count by word&lt;/P&gt;

&lt;P&gt;The above gives me Error in 'eval' command: The expression is malformed.&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 16:42:59 GMT</pubDate>
    <dc:creator>zacksoft</dc:creator>
    <dc:date>2020-09-29T16:42:59Z</dc:date>
    <item>
      <title>How do I create a piechart visualization with the count of two field values and the sum of both displayed?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-piechart-visualization-with-the-count-of-two/m-p/360462#M106537</link>
      <description>&lt;P&gt;I have a query that gives me the count of certain events with keyword 'ab' OR with keyword 'pq'.&lt;BR /&gt;
The query is like this&lt;/P&gt;

&lt;P&gt;host="somehost1" OR "somehost2" OR "somehost3"&lt;BR /&gt;
("ab" OR "pq") &lt;BR /&gt;
| eval count_1 = if(like(_raw,"%ab%") &lt;BR /&gt;
| eval count_2 = if(like(_raw,"%pq%") &lt;BR /&gt;
| stats count(count_1) as ab_EventCount sum(count_2) as pq_EventCount&lt;/P&gt;

&lt;P&gt;This query gives me the event count with keyword 'ab' and keyword 'pq' in a tabular format in the statistics tab.&lt;BR /&gt;
I wanted a visualization in Pie chart with showing the percentage of ab_EventCount in one slice , pq_Eventcount in another slice out of the total events this query gives us. But when I choose visualization tab it doesn't happen. The pie shows all wrong.&lt;BR /&gt;
Could anyone guide me  ?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:42:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-piechart-visualization-with-the-count-of-two/m-p/360462#M106537</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2020-09-29T16:42:56Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a piechart visualization with the count of two field values and the sum of both displayed?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-piechart-visualization-with-the-count-of-two/m-p/360463#M106538</link>
      <description>&lt;P&gt;Hi zacksoft,&lt;BR /&gt;
try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host="somehost1" OR "somehost2" OR "somehost3" ("ab" OR "pq") 
| eval word1=if(like(_raw,"%ab%"),"ab"," "),word2=if(like(_raw,"%pq%"),"pq"," "),word=coalesce(word1,word2)
| stats count by word
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If it doesn't run put a char (e.g."-") in the eval if)&lt;BR /&gt;
and then shot them in a pie.&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 11:30:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-piechart-visualization-with-the-count-of-two/m-p/360463#M106538</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-11-13T11:30:44Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a piechart visualization with the count of two field values and the sum of both displayed?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-piechart-visualization-with-the-count-of-two/m-p/360464#M106539</link>
      <description>&lt;P&gt;@Anonymous&lt;BR /&gt;
Hi Giuseppe- Thank you . this works.&lt;BR /&gt;
However, If I am to search two words instead of just ab, how would I tweak the string.&lt;BR /&gt;
Example : I want (ab AND null1) to be counted and (pq AND null2) to be counted.&lt;BR /&gt;
Is the following line correct (syntax wise) ?&lt;/P&gt;

&lt;P&gt;| eval word=case(like(_raw,"%ab%") AND like(_raw,"%null1%),"ab",like(_raw,"%pq%") AND like(_raw,"%null2%),"pq") &lt;BR /&gt;
| stats count by word&lt;/P&gt;

&lt;P&gt;The above gives me Error in 'eval' command: The expression is malformed.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:42:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-piechart-visualization-with-the-count-of-two/m-p/360464#M106539</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2020-09-29T16:42:59Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a piechart visualization with the count of two field values and the sum of both displayed?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-piechart-visualization-with-the-count-of-two/m-p/360465#M106540</link>
      <description>&lt;P&gt;HI &lt;BR /&gt;
Can you please try this one?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host="somehost1" OR "somehost2" OR "somehost3" ("ab" OR "pq") | eval count_1 = if(like(_raw,"%ab%")) | eval count_2 = if(like(_raw,"%pq%")) | stats count(count_1) as ab_EventCount sum(count_2) as pq_EventCount  | transpose
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have just added &lt;CODE&gt;| transpose&lt;/CODE&gt; to your search.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 11:51:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-piechart-visualization-with-the-count-of-two/m-p/360465#M106540</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2017-11-13T11:51:52Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a piechart visualization with the count of two field values and the sum of both displayed?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-piechart-visualization-with-the-count-of-two/m-p/360466#M106541</link>
      <description>&lt;P&gt;Thanks Giuseppe. The solution you provided works like a charm.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 12:00:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-piechart-visualization-with-the-count-of-two/m-p/360466#M106541</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2017-11-13T12:00:20Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a piechart visualization with the count of two field values and the sum of both displayed?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-piechart-visualization-with-the-count-of-two/m-p/360467#M106542</link>
      <description>&lt;P&gt;Thanks kamlesh. The solution you provided works &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 12:03:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-piechart-visualization-with-the-count-of-two/m-p/360467#M106542</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2017-11-13T12:03:36Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a piechart visualization with the count of two field values and the sum of both displayed?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-piechart-visualization-with-the-count-of-two/m-p/360468#M106543</link>
      <description>&lt;P&gt;Welcome @zacksoft,&lt;/P&gt;

&lt;P&gt;Please accept  @cusello or my answer and upvote the comments that help you to close this question.&lt;/P&gt;

&lt;P&gt;Happy Splunking &lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 12:07:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-piechart-visualization-with-the-count-of-two/m-p/360468#M106543</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2017-11-13T12:07:17Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a piechart visualization with the count of two field values and the sum of both displayed?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-piechart-visualization-with-the-count-of-two/m-p/360469#M106544</link>
      <description>&lt;P&gt;Since there is already an accepted answer, I am adding &lt;CODE&gt;searchmatch()&lt;/CODE&gt; example which is used for searching pattern within raw data.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; host="somehost1" OR "somehost2" OR "somehost3" ("ab" OR "pq")
| stats count(eval(searchmatch("ab"))) as ab_count count(eval(searchmatch("pq"))) as pq_count
| transpose
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/CommonEvalFunctions"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/CommonEvalFunctions&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 12:47:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-piechart-visualization-with-the-count-of-two/m-p/360469#M106544</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-11-13T12:47:59Z</dc:date>
    </item>
  </channel>
</rss>

