<?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 define results from an initial search as a variable for other searches? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-define-results-from-an-initial-search-as-a-variable-for/m-p/118772#M31762</link>
    <description>&lt;P&gt;Once you have a selection for eye in &lt;CODE&gt;selected_eyes&lt;/CODE&gt; and hair in &lt;CODE&gt;selected_hair&lt;/CODE&gt;, and your data uses fields &lt;CODE&gt;Eye Color&lt;/CODE&gt; and &lt;CODE&gt;Hair Color&lt;/CODE&gt;,  you can do it like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats count(eval($Eye Color$=selected_eyes)) AS "Eye Color Count" count(eval($Hair Color$=selected_hair)) AS "Hair Color Count" | rename selected_eyes AS "Eye Color" selected_hair AS "Hair Color" | table "Eye Color" "Eye Color Count" "Hair Color" "Hair Color Count"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 13 Jul 2015 21:51:59 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2015-07-13T21:51:59Z</dc:date>
    <item>
      <title>How to define results from an initial search as a variable for other searches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-define-results-from-an-initial-search-as-a-variable-for/m-p/118770#M31760</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I am working on a search and eventually a dashboard that displays the count per field based on the characteristics or results from an initial search. I'm pulling all my data into Splunk using the DB connect app.&lt;/P&gt;

&lt;P&gt;For example, let's assume our entire data set consists of three fields (ID, eye color, and hair color) and four events.&lt;BR /&gt;
Silly example, but bare with me.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ID          Eye Color          Hair Color
1           Blue               Brown
2           Green              Brown
3           Blue               Black
4           Brown              Brown
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now we want to find the count of IDs for each field based off the characteristics of a specified ID. In other words, if we choose &lt;STRONG&gt;ID 1&lt;/STRONG&gt; as our input, then with some Splunk magic the dashboard will spit out the following table (Note: I am not worried too much about formatting at this point).&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Eye Color      Eye Color Count      Hair Color     Hair Color Count
Blue                  2               Brown               3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Does anyone have any ideas how I can go about writing this search? I originally thought I could pull in two sets of data (all the data and the row I want to pivot off of) and then either append or join the two sets together.&lt;/P&gt;

&lt;P&gt;Thanks in advance, please let me know if my questions makes sense or if I need to clear something up.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jul 2015 21:37:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-define-results-from-an-initial-search-as-a-variable-for/m-p/118770#M31760</guid>
      <dc:creator>BWhisler2015</dc:creator>
      <dc:date>2015-07-13T21:37:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to define results from an initial search as a variable for other searches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-define-results-from-an-initial-search-as-a-variable-for/m-p/118771#M31761</link>
      <description>&lt;P&gt;The easiest to write would be something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  sourcetype=your_data [search sourcetype=your_data ID=1 | table eye_color] | stats count as "Eye Color Count" by eye_color
| appendcols [search sourcetype=your_data [search sourcetype=your_data ID=1 | table hair_color] | stats count as "Hair Color Count" by hair_color
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That'll go through your data several times, picking out the parts you need at each go.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jul 2015 21:46:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-define-results-from-an-initial-search-as-a-variable-for/m-p/118771#M31761</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2015-07-13T21:46:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to define results from an initial search as a variable for other searches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-define-results-from-an-initial-search-as-a-variable-for/m-p/118772#M31762</link>
      <description>&lt;P&gt;Once you have a selection for eye in &lt;CODE&gt;selected_eyes&lt;/CODE&gt; and hair in &lt;CODE&gt;selected_hair&lt;/CODE&gt;, and your data uses fields &lt;CODE&gt;Eye Color&lt;/CODE&gt; and &lt;CODE&gt;Hair Color&lt;/CODE&gt;,  you can do it like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats count(eval($Eye Color$=selected_eyes)) AS "Eye Color Count" count(eval($Hair Color$=selected_hair)) AS "Hair Color Count" | rename selected_eyes AS "Eye Color" selected_hair AS "Hair Color" | table "Eye Color" "Eye Color Count" "Hair Color" "Hair Color Count"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Jul 2015 21:51:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-define-results-from-an-initial-search-as-a-variable-for/m-p/118772#M31762</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-07-13T21:51:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to define results from an initial search as a variable for other searches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-define-results-from-an-initial-search-as-a-variable-for/m-p/118773#M31763</link>
      <description>&lt;P&gt;Thanks! This works!&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2015 17:44:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-define-results-from-an-initial-search-as-a-variable-for/m-p/118773#M31763</guid>
      <dc:creator>BWhisler2015</dc:creator>
      <dc:date>2015-07-14T17:44:25Z</dc:date>
    </item>
  </channel>
</rss>

