<?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 get distinct values for a derived field in a search? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-distinct-values-for-a-derived-field-in-a-search/m-p/53693#M13058</link>
    <description>&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/4.2.2/SearchReference/CommonStatsFunctions"&gt;http://docs.splunk.com/Documentation/Splunk/4.2.2/SearchReference/CommonStatsFunctions&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;values(X)   This function returns the list of all distinct values of the field X as a multi-value entry. The order of the values is lexicographical. 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So if the values in your example are extracted as a multi-valued field called, say, "foo", you would do something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats values(foo)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 18 Jan 2012 21:03:32 GMT</pubDate>
    <dc:creator>Ayn</dc:creator>
    <dc:date>2012-01-18T21:03:32Z</dc:date>
    <item>
      <title>How do I get distinct values for a derived field in a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-distinct-values-for-a-derived-field-in-a-search/m-p/53692#M13057</link>
      <description>&lt;P&gt;Good afternoon all,&lt;/P&gt;

&lt;P&gt;I have a datasource that I've used transforms.conf and props.conf to create a "field" derived from a comma-delimited portion of each event.  How do I get a list of the distinct values?&lt;/P&gt;

&lt;P&gt;For example, if I have three events:&lt;BR /&gt;&lt;BR /&gt;
[A, B, C, D]&lt;BR /&gt;&lt;BR /&gt;
[D, E, F, G]&lt;BR /&gt;&lt;BR /&gt;
[A, G, C, Z]  &lt;/P&gt;

&lt;P&gt;How do I get a resultset that gives me "A", "B", "C", "D", "E", "F", "G", "Z" and no counts or any other information?&lt;/P&gt;

&lt;P&gt;I already have the transforms.conf and props.conf pulling out the values for the "tags", but not a way to say "Here are all of the values for that field".  In SQL, I'd use "SELECT DISTINCT TEXT FROM MYTAGS...", but I don't know about the Splunk query values.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2012 19:09:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-distinct-values-for-a-derived-field-in-a-search/m-p/53692#M13057</guid>
      <dc:creator>wwhitener</dc:creator>
      <dc:date>2012-01-18T19:09:56Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get distinct values for a derived field in a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-distinct-values-for-a-derived-field-in-a-search/m-p/53693#M13058</link>
      <description>&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/4.2.2/SearchReference/CommonStatsFunctions"&gt;http://docs.splunk.com/Documentation/Splunk/4.2.2/SearchReference/CommonStatsFunctions&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;values(X)   This function returns the list of all distinct values of the field X as a multi-value entry. The order of the values is lexicographical. 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So if the values in your example are extracted as a multi-valued field called, say, "foo", you would do something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats values(foo)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Jan 2012 21:03:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-distinct-values-for-a-derived-field-in-a-search/m-p/53693#M13058</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2012-01-18T21:03:32Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get distinct values for a derived field in a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-distinct-values-for-a-derived-field-in-a-search/m-p/53694#M13059</link>
      <description>&lt;P&gt;I guess I went the wrong way around it then.&lt;BR /&gt;
source="mysource.log" | stats count by myfield | fields myfield&lt;BR /&gt;
It was to populate a form dropdown, so ultimately even the "fields" functions is not really needed for what I wanted.&lt;BR /&gt;
Thanks for the answer! I'll try it your way too.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2012 21:06:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-distinct-values-for-a-derived-field-in-a-search/m-p/53694#M13059</guid>
      <dc:creator>wwhitener</dc:creator>
      <dc:date>2012-01-18T21:06:21Z</dc:date>
    </item>
  </channel>
</rss>

