<?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 you create a crosstab with sparse data? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-create-a-crosstab-with-sparse-data/m-p/448561#M176991</link>
    <description>&lt;P&gt;This answer works as well, and perhaps is slightly cleaner.&lt;BR /&gt;
@eykrevooh's answer was posted first and thus I accepted it.&lt;/P&gt;</description>
    <pubDate>Fri, 08 Feb 2019 14:25:31 GMT</pubDate>
    <dc:creator>jfriedman_ofigl</dc:creator>
    <dc:date>2019-02-08T14:25:31Z</dc:date>
    <item>
      <title>How do you create a crosstab with sparse data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-create-a-crosstab-with-sparse-data/m-p/448558#M176988</link>
      <description>&lt;P&gt;My vulnerability data looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Machine  MachineType  VulnCode  Impact
-------  -----------  --------  ------
A        X            100       5
A        X            101       4
A        X            102       3
A        X            103       5
B        X            200       5
B        X            201       3
C        Y            101       4
D        Y            200       5
D        Y            201       3
E        Z            103       5
F        Z            201       3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want a result like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;MachineType  Impact=5  Impact=4  Impact=3
-----------  --------  --------  --------
X            3         1         2
Y            1         1         1
Z            1         0         1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I tried appendcols with a savedsearch but got &lt;CODE&gt;Found circular dependency when expanding savedsearch&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Feb 2019 22:10:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-create-a-crosstab-with-sparse-data/m-p/448558#M176988</guid>
      <dc:creator>jfriedman_ofigl</dc:creator>
      <dc:date>2019-02-07T22:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: How do you create a crosstab with sparse data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-create-a-crosstab-with-sparse-data/m-p/448559#M176989</link>
      <description>&lt;P&gt;This would be case to use the &lt;A href="https://docs.splunk.com/Documentation/Splunk/7.2.3/SearchReference/Xyseries"&gt;xyseries&lt;/A&gt; command.&lt;/P&gt;

&lt;P&gt;First you want to get a count by the number of Machine Types and the Impacts. &lt;BR /&gt;
&lt;CODE&gt;| stats count by MachineType, Impact&lt;/CODE&gt;&lt;BR /&gt;
Once you have the count you can use xyseries command to set the x axis as Machine Types, the y axis as the Impact, and their value as count.&lt;BR /&gt;
&lt;CODE&gt;| xyseries MachineType, Impact, count&lt;/CODE&gt;&lt;BR /&gt;
This will produce a table like you have above, the only difference is that any place where there would be a 0 it would be null. If you want zeros in there place you can use fillnull.&lt;BR /&gt;
&lt;CODE&gt;| fillnull value=0&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Example Full Command:&lt;BR /&gt;
&lt;CODE&gt;| stats count by MachineType, Impact&lt;BR /&gt;
| xyseries MachineType, Impact, count&lt;BR /&gt;
| fillnull value=0&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Feb 2019 23:22:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-create-a-crosstab-with-sparse-data/m-p/448559#M176989</guid>
      <dc:creator>eykrevooh</dc:creator>
      <dc:date>2019-02-07T23:22:44Z</dc:date>
    </item>
    <item>
      <title>Re: How do you create a crosstab with sparse data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-create-a-crosstab-with-sparse-data/m-p/448560#M176990</link>
      <description>&lt;P&gt;I think you just need to make impact that way you want and then use chart to format.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your search&amp;gt;
| eval Impact = "Impact=" . Impact
| chart count over MachineType by Impact
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Feb 2019 23:28:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-create-a-crosstab-with-sparse-data/m-p/448560#M176990</guid>
      <dc:creator>maciep</dc:creator>
      <dc:date>2019-02-07T23:28:15Z</dc:date>
    </item>
    <item>
      <title>Re: How do you create a crosstab with sparse data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-create-a-crosstab-with-sparse-data/m-p/448561#M176991</link>
      <description>&lt;P&gt;This answer works as well, and perhaps is slightly cleaner.&lt;BR /&gt;
@eykrevooh's answer was posted first and thus I accepted it.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Feb 2019 14:25:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-create-a-crosstab-with-sparse-data/m-p/448561#M176991</guid>
      <dc:creator>jfriedman_ofigl</dc:creator>
      <dc:date>2019-02-08T14:25:31Z</dc:date>
    </item>
    <item>
      <title>Re: How do you create a crosstab with sparse data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-create-a-crosstab-with-sparse-data/m-p/448562#M176992</link>
      <description>&lt;P&gt;understood...important thing is you got what you needed.  And although xyseries may not be needed for this particular case, keep it in your toolbox, because it can definitely come in handy&lt;/P&gt;</description>
      <pubDate>Fri, 08 Feb 2019 14:33:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-create-a-crosstab-with-sparse-data/m-p/448562#M176992</guid>
      <dc:creator>maciep</dc:creator>
      <dc:date>2019-02-08T14:33:00Z</dc:date>
    </item>
  </channel>
</rss>

