<?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 How to create a bar graph based on two fields in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-a-bar-graph-based-on-two-fields/m-p/329088#M40243</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I've got two fields:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;04_DEC_2017      05_DEC_2017
5                     5
6                     6
7                     9
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to create a bar graph with the dates     04_DEC_2017      05_DEC_2017 on the axis and the sum for each field plotted on the graph.&lt;/P&gt;

&lt;P&gt;So this is what I've got at the moment:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=xxxsourcetype=csv source=xxxx| table DEPT, *_2017, *_2018 | fields - 03_DEC_2017 | fillnull | where DEPT=xx OR DEPT=xxOR DEPT=xxOR DEPT=xxOR DEPT=xxOR DEPT=xx OR DEPT=xx OR DEPT=xx OR DEPT=xx OR DEPT=xx| stats sum(*_2017)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any ideas?&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 17:09:02 GMT</pubDate>
    <dc:creator>mahbs</dc:creator>
    <dc:date>2020-09-29T17:09:02Z</dc:date>
    <item>
      <title>How to create a bar graph based on two fields</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-a-bar-graph-based-on-two-fields/m-p/329088#M40243</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I've got two fields:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;04_DEC_2017      05_DEC_2017
5                     5
6                     6
7                     9
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to create a bar graph with the dates     04_DEC_2017      05_DEC_2017 on the axis and the sum for each field plotted on the graph.&lt;/P&gt;

&lt;P&gt;So this is what I've got at the moment:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=xxxsourcetype=csv source=xxxx| table DEPT, *_2017, *_2018 | fields - 03_DEC_2017 | fillnull | where DEPT=xx OR DEPT=xxOR DEPT=xxOR DEPT=xxOR DEPT=xxOR DEPT=xx OR DEPT=xx OR DEPT=xx OR DEPT=xx OR DEPT=xx| stats sum(*_2017)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any ideas?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:09:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-a-bar-graph-based-on-two-fields/m-p/329088#M40243</guid>
      <dc:creator>mahbs</dc:creator>
      <dc:date>2020-09-29T17:09:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a bar graph based on two fields</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-a-bar-graph-based-on-two-fields/m-p/329089#M40244</link>
      <description>&lt;P&gt;Hi @mahbs,&lt;/P&gt;

&lt;P&gt;Can you please try below query ?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval 04_DEC_17=4, 05_DEC_17=5
| append [ | makeresults | eval 04_DEC_17=4, 05_DEC_17=6 ]
| eval tmp=1
| chart sum(*_17) AS *_17 over tmp
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Dec 2017 11:59:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-a-bar-graph-based-on-two-fields/m-p/329089#M40244</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2017-12-06T11:59:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a bar graph based on two fields</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-a-bar-graph-based-on-two-fields/m-p/329090#M40245</link>
      <description>&lt;P&gt;Hi, the query is good, but the only issue is, the dates are automatically populated from data sent by a database periodically.  &lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2017 12:49:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-a-bar-graph-based-on-two-fields/m-p/329090#M40245</guid>
      <dc:creator>mahbs</dc:creator>
      <dc:date>2017-12-06T12:49:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a bar graph based on two fields</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-a-bar-graph-based-on-two-fields/m-p/329091#M40246</link>
      <description>&lt;P&gt;ok, so can't you run below this query based on query which you provided ?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=xxxsourcetype=csv source=xxxx| table DEPT, *_2017, *_2018 | fields - 03_DEC_2017 | fillnull | where DEPT=xx OR DEPT=xxOR DEPT=xxOR DEPT=xxOR DEPT=xxOR DEPT=xx OR DEPT=xx OR DEPT=xx OR DEPT=xx OR DEPT=xx
| eval tmp=1
| chart sum(*_2017) AS *_2017 over tmp
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Dec 2017 12:57:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-a-bar-graph-based-on-two-fields/m-p/329091#M40246</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2017-12-06T12:57:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a bar graph based on two fields</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-a-bar-graph-based-on-two-fields/m-p/329092#M40247</link>
      <description>&lt;P&gt;this will get you a sum of each date by dept (in the transpose, the &lt;CODE&gt;0&lt;/CODE&gt; indicates no limit to how many columns/rows get transposed):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=xxxsourcetype=csv source=xxxx (DEPT=xx OR DEPT=xx OR DEPT=xx OR DEPT=xx OR DEPT=xx OR DEPT=xx OR DEPT=xx OR DEPT=xx OR DEPT=xx OR DEPT=xx)| table DEPT, *_2017, *_2018 | fields - 03_DEC_2017 | fillnull | stats sum(*) as * by DEPT|transpose 0 header_field=DEPT column_name=DEPT
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and this should get you the sum for all depts by basically creating a dummy field (called &lt;CODE&gt;dept&lt;/CODE&gt;) and using that as the by command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=xxxsourcetype=csv source=xxxx (DEPT=xx OR DEPT=xx OR DEPT=xx OR DEPT=xx OR DEPT=xx OR DEPT=xx OR DEPT=xx OR DEPT=xx OR DEPT=xx OR DEPT=xx)| table DEPT, *_2017, *_2018 | fields - 03_DEC_2017 | fillnull |eval dept="all depts"| stats sum(*) as * by dept|transpose 0 header_field=dept column_name=dept
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Dec 2017 13:29:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-a-bar-graph-based-on-two-fields/m-p/329092#M40247</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2017-12-07T13:29:52Z</dc:date>
    </item>
  </channel>
</rss>

