<?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: Create a stacked bar chart, conflating values from multiple fields in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Create-a-stacked-bar-chart-conflating-values-from-multiple/m-p/346734#M22619</link>
    <description>&lt;P&gt;@cmerriman, yes but your query should work. It worked for me as well. Could it be that field names parameters.From and params.from are something else in raw data?&lt;/P&gt;

&lt;P&gt;@sjb300, can you check if the following works&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;YourBaseSearch&amp;gt;
| table "parameters.From" "params.from"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 08 Nov 2017 19:44:54 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2017-11-08T19:44:54Z</dc:date>
    <item>
      <title>Create a stacked bar chart, conflating values from multiple fields</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Create-a-stacked-bar-chart-conflating-values-from-multiple/m-p/346724#M22609</link>
      <description>&lt;P&gt;Each event in my data set falls into one of two categories:&lt;BR /&gt;
1) Has a field called "os_platform" and a field called "parameters.From"&lt;BR /&gt;
2) Has a field called "os" and a field called "params.from"&lt;/P&gt;

&lt;P&gt;I would like to generate a stacked bar chart where there is one bar per value of either os or os_platform (whichever is present for each event), and where each bar is split into a segment for each value of parameters.From or params.from (whichever is present for each event).&lt;/P&gt;

&lt;P&gt;What would a query look like which does this?&lt;/P&gt;

&lt;P&gt;This data...&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/3791i4B838699D33F337C/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;...should produce a chart that looks like this...&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/3792i810F8745BB0F245A/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2017 09:50:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Create-a-stacked-bar-chart-conflating-values-from-multiple/m-p/346724#M22609</guid>
      <dc:creator>sjb300</dc:creator>
      <dc:date>2017-11-08T09:50:20Z</dc:date>
    </item>
    <item>
      <title>Re: Create a stacked bar chart, conflating values from multiple fields</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Create-a-stacked-bar-chart-conflating-values-from-multiple/m-p/346725#M22610</link>
      <description>&lt;P&gt;@sjb300, can you add a mock screenshot of what you need and some sample data for 4 fields as to how they would appear in event?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2017 15:32:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Create-a-stacked-bar-chart-conflating-values-from-multiple/m-p/346725#M22610</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-11-08T15:32:43Z</dc:date>
    </item>
    <item>
      <title>Re: Create a stacked bar chart, conflating values from multiple fields</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Create-a-stacked-bar-chart-conflating-values-from-multiple/m-p/346726#M22611</link>
      <description>&lt;P&gt;@niketnilay Done&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2017 15:48:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Create-a-stacked-bar-chart-conflating-values-from-multiple/m-p/346726#M22611</guid>
      <dc:creator>sjb300</dc:creator>
      <dc:date>2017-11-08T15:48:41Z</dc:date>
    </item>
    <item>
      <title>Re: Create a stacked bar chart, conflating values from multiple fields</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Create-a-stacked-bar-chart-conflating-values-from-multiple/m-p/346727#M22612</link>
      <description>&lt;P&gt;you'll need something like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|eval os_type=coalesce(os,os_platform)
|eval param=coalesce('parameters.From','params.from')
|chart count by param os_type
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Nov 2017 17:10:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Create-a-stacked-bar-chart-conflating-values-from-multiple/m-p/346727#M22612</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2017-11-08T17:10:47Z</dc:date>
    </item>
    <item>
      <title>Re: Create a stacked bar chart, conflating values from multiple fields</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Create-a-stacked-bar-chart-conflating-values-from-multiple/m-p/346728#M22613</link>
      <description>&lt;P&gt;Using that example, if I replace line 3 with "chart count by os_type" then it produces a bar chart by OS. If I do "chart count by param" instead, it says "No results found", even though I have not added anything that should filter the results. What's going on?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2017 17:19:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Create-a-stacked-bar-chart-conflating-values-from-multiple/m-p/346728#M22613</guid>
      <dc:creator>sjb300</dc:creator>
      <dc:date>2017-11-08T17:19:19Z</dc:date>
    </item>
    <item>
      <title>Re: Create a stacked bar chart, conflating values from multiple fields</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Create-a-stacked-bar-chart-conflating-values-from-multiple/m-p/346729#M22614</link>
      <description>&lt;P&gt;Can this be because parameters and params are arrays?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2017 17:23:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Create-a-stacked-bar-chart-conflating-values-from-multiple/m-p/346729#M22614</guid>
      <dc:creator>sjb300</dc:creator>
      <dc:date>2017-11-08T17:23:32Z</dc:date>
    </item>
    <item>
      <title>Re: Create a stacked bar chart, conflating values from multiple fields</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Create-a-stacked-bar-chart-conflating-values-from-multiple/m-p/346730#M22615</link>
      <description>&lt;P&gt;Found something that works, although somewhat inelegant:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| spath output=from1 path=params.From
| spath output=from2 path=parameters.from
| eval from=coalesce(from1,from2)
| eval os=coalesce(os,os_platform)
| chart count by os, from
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Nov 2017 18:02:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Create-a-stacked-bar-chart-conflating-values-from-multiple/m-p/346730#M22615</guid>
      <dc:creator>sjb300</dc:creator>
      <dc:date>2017-11-08T18:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: Create a stacked bar chart, conflating values from multiple fields</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Create-a-stacked-bar-chart-conflating-values-from-multiple/m-p/346731#M22616</link>
      <description>&lt;P&gt;try using either &lt;CODE&gt;|eval param=coalesce("parameters.From","params.from")&lt;/CODE&gt; or &lt;CODE&gt;|eval param=coalesce(parameters.From,params.from)&lt;/CODE&gt;&lt;BR /&gt;
Splunk can be picky about field names with &lt;CODE&gt;.&lt;/CODE&gt; and spaces. See if &lt;CODE&gt;param&lt;/CODE&gt; is a field now.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2017 18:15:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Create-a-stacked-bar-chart-conflating-values-from-multiple/m-p/346731#M22616</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2017-11-08T18:15:51Z</dc:date>
    </item>
    <item>
      <title>Re: Create a stacked bar chart, conflating values from multiple fields</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Create-a-stacked-bar-chart-conflating-values-from-multiple/m-p/346732#M22617</link>
      <description>&lt;P&gt;@cmerriman, your first query for &lt;CODE&gt;coalesce()&lt;/CODE&gt; with single quotes for field name is correct. While creating the chart you should have mentioned &lt;CODE&gt;|chart count over os_type by param&lt;/CODE&gt;. Please correct the same it should work.&lt;/P&gt;

&lt;P&gt;@sjb300 please try out the following run anywhere search with sample data from the question. This is on similar lines as Clara, however, while performing coalesce(), it reuses one of the existing fields instead of creating new ones. Also &lt;CODE&gt;fields -&lt;/CODE&gt; is added to remove other fields after coalesce().&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|  makeresults
|  eval "Event id"=1,"parameters.From"="A","os_platform"="x86"
|  append 
    [|  makeresults
     |  eval "Event id"=2,"parameters.From"="A","os_platform"="x86"]
|  append 
    [|  makeresults
     |  eval "Event id"=3,"params.from"="B","os"="Android"]
|  append 
    [|  makeresults
     |  eval "Event id"=4,"params.from"="B","os"="iOS"]
|  append 
    [|  makeresults
     |  eval "Event id"=5,"params.from"="A","os"="iOS"]
|  append 
    [|  makeresults
     |  eval "Event id"=5,"params.from"="A","os"="iOS"]
| table "Event id" "parameters.From" "params.from" "os_platform" "os"
| eval params.from=coalesce('parameters.From','params.from')
| eval os=coalesce('os_platform','os')
| fields - "parameters.From" "os_platform"
| chart count over os by "params.from"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Nov 2017 18:45:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Create-a-stacked-bar-chart-conflating-values-from-multiple/m-p/346732#M22617</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-11-08T18:45:59Z</dc:date>
    </item>
    <item>
      <title>Re: Create a stacked bar chart, conflating values from multiple fields</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Create-a-stacked-bar-chart-conflating-values-from-multiple/m-p/346733#M22618</link>
      <description>&lt;P&gt;the chart command does not need &lt;CODE&gt;over &amp;lt;&amp;lt;FIELD1&amp;gt;&amp;gt; by &amp;lt;&amp;lt;FIELD2&amp;gt;&amp;gt;&lt;/CODE&gt; to work. it understand that &lt;CODE&gt;by &amp;lt;&amp;lt;FIELD1&amp;gt;&amp;gt; &amp;lt;&amp;lt;FIELD2&amp;gt;&amp;gt; is the&lt;/CODE&gt;over&lt;CODE&gt;and&lt;/CODE&gt;by` automatically.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults|eval data="id=1,from=A,os_platform=x86 id=2,from=A,os_platform=x86 id=3,from1=B,os=Android id=4,from1=B,os=iOS id=5,from1=A,os=iOS id=6,from1=A,os=iOS"|makemv data|mvexpand data|rename data as _raw |kv|rename from as "parameters.From" from1 as "params.from"
|eval os_type=coalesce(os,os_platform)
 |eval param=coalesce('parameters.From','params.from')
 |chart count by os_type param
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Nov 2017 19:40:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Create-a-stacked-bar-chart-conflating-values-from-multiple/m-p/346733#M22618</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2017-11-08T19:40:54Z</dc:date>
    </item>
    <item>
      <title>Re: Create a stacked bar chart, conflating values from multiple fields</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Create-a-stacked-bar-chart-conflating-values-from-multiple/m-p/346734#M22619</link>
      <description>&lt;P&gt;@cmerriman, yes but your query should work. It worked for me as well. Could it be that field names parameters.From and params.from are something else in raw data?&lt;/P&gt;

&lt;P&gt;@sjb300, can you check if the following works&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;YourBaseSearch&amp;gt;
| table "parameters.From" "params.from"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Nov 2017 19:44:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Create-a-stacked-bar-chart-conflating-values-from-multiple/m-p/346734#M22619</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-11-08T19:44:54Z</dc:date>
    </item>
  </channel>
</rss>

