<?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: Lookup command distinct column values in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Lookup-command-distinct-column-values/m-p/332117#M61502</link>
    <description>&lt;P&gt;Thank you for the followup, I just have one more question.  How was I to know that this field would become multivalued.  If I omit the mvindex command, I do not see a comma delimited list or anything like that. I don't even see something like "y1, y1, y1".  &lt;/P&gt;</description>
    <pubDate>Wed, 31 May 2017 19:00:53 GMT</pubDate>
    <dc:creator>matthewb4</dc:creator>
    <dc:date>2017-05-31T19:00:53Z</dc:date>
    <item>
      <title>Lookup command distinct column values</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Lookup-command-distinct-column-values/m-p/332112#M61497</link>
      <description>&lt;P&gt;I am trying to copy the counts of field X (already in logs) into a new field Y (from a lookup csv)  so that they have the exact same counts but field Y has better named values.&lt;/P&gt;

&lt;P&gt;The problem I am running into is that my csv file has multiple of the same X values in it so instead of field Y ending up with the same counts as field X, it is becoming (X * # of matched duplicates in csv).  Is there any way for me to only get distinct rows from a lookup csv based on the matching field value (X in this case).&lt;/P&gt;

&lt;P&gt;I am currently just using this... "lookup test.csv X AS X OUTPUTNEW Y AS Y"&lt;/P&gt;

&lt;P&gt;And my csv file look something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Y      X      Z

y1  |  x1  |  z1
y1  |  x1  |  z2
y1  |  x1  |  z3
y2  |  x2  |  z1
y2  |  x2  |  z2
y3  |  x3  |  z1
y3  |  x3  |  z2
y3  |  x3  |  z3
y3  |  x3  |  z4
y3  |  x3  |  z5
y3  |  x3  |  z6
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Given the previous csv file, if my counts for x1 in splunk logs were 1000, my new y1 value in field Y would get the value 3000.  This is unwanted behavior for me, I would like for them to be the same.  Any help on how I can modify my query is greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 17:29:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Lookup-command-distinct-column-values/m-p/332112#M61497</guid>
      <dc:creator>matthewb4</dc:creator>
      <dc:date>2017-05-31T17:29:49Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup command distinct column values</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Lookup-command-distinct-column-values/m-p/332113#M61498</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | lookup test.csv X OUTPUTNEW Y | eval Y = mvindex(Y, 0) | ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 31 May 2017 18:13:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Lookup-command-distinct-column-values/m-p/332113#M61498</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-05-31T18:13:51Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup command distinct column values</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Lookup-command-distinct-column-values/m-p/332114#M61499</link>
      <description>&lt;P&gt;Great! This worked, do you mind explaining what mvindex is doing exactly? Each time outputnew is run for a specific Y value is it appending it to a multivalue list?  I thought that it was simply adding to the current count, not creating a new index every time.&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 18:21:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Lookup-command-distinct-column-values/m-p/332114#M61499</guid>
      <dc:creator>matthewb4</dc:creator>
      <dc:date>2017-05-31T18:21:23Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup command distinct column values</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Lookup-command-distinct-column-values/m-p/332115#M61500</link>
      <description>&lt;P&gt;The lookup is creating a multivalued field so we just take the first value and throw away the rest.  Probably an even better solution would be to use &lt;CODE&gt;| eval Y = mvdedup(Y)&lt;/CODE&gt; which would keep every distinct value of &lt;CODE&gt;Y&lt;/CODE&gt; (which, if your lookup is correct should be only a single value, but if the lookup is broken, this version of the solution would give you some hope of discovering that).&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 18:30:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Lookup-command-distinct-column-values/m-p/332115#M61500</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-05-31T18:30:20Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup command distinct column values</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Lookup-command-distinct-column-values/m-p/332116#M61501</link>
      <description>&lt;P&gt;Don't forget to click &lt;CODE&gt;Accept&lt;/CODE&gt;!&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 18:31:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Lookup-command-distinct-column-values/m-p/332116#M61501</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-05-31T18:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup command distinct column values</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Lookup-command-distinct-column-values/m-p/332117#M61502</link>
      <description>&lt;P&gt;Thank you for the followup, I just have one more question.  How was I to know that this field would become multivalued.  If I omit the mvindex command, I do not see a comma delimited list or anything like that. I don't even see something like "y1, y1, y1".  &lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 19:00:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Lookup-command-distinct-column-values/m-p/332117#M61502</guid>
      <dc:creator>matthewb4</dc:creator>
      <dc:date>2017-05-31T19:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup command distinct column values</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Lookup-command-distinct-column-values/m-p/332118#M61503</link>
      <description>&lt;P&gt;A single value of &lt;CODE&gt;X&lt;/CODE&gt; has multiple values of &lt;CODE&gt;Y&lt;/CODE&gt; in your lookup file.  How else could this be sensibly handled other than to create a multivalued output for &lt;CODE&gt;Y&lt;/CODE&gt;.  I guess the answer is "common sense" but maybe not totally obvious.  I have requested Splunk update the documentation here:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.6.0/SearchReference/Lookup"&gt;http://docs.splunk.com/Documentation/Splunk/6.6.0/SearchReference/Lookup&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 19:10:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Lookup-command-distinct-column-values/m-p/332118#M61503</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-05-31T19:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup command distinct column values</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Lookup-command-distinct-column-values/m-p/332119#M61504</link>
      <description>&lt;P&gt;Would there be any way for me to see this multivalued list as a sanity check.  I only see the combined chunk count for each new Y value, which is limiting my comprehension a bit.  I think why this is most troubling to me is that when you said " single value of X has multiple values of Y in your lookup file. How else could this be sensibly handled other than to create a multivalued output for Y?"  In my case the multiple values of Y are actually all the exact same string for the same X, I'm guessing this is why it's not actually showing up as a list but being treated as one?&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 19:26:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Lookup-command-distinct-column-values/m-p/332119#M61504</guid>
      <dc:creator>matthewb4</dc:creator>
      <dc:date>2017-05-31T19:26:27Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup command distinct column values</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Lookup-command-distinct-column-values/m-p/332120#M61505</link>
      <description>&lt;P&gt;Sure, do this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... lookup test.csv X OUTPUTNEW Y | nomv Y ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will flatten the list into a single value.&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 19:30:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Lookup-command-distinct-column-values/m-p/332120#M61505</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-05-31T19:30:16Z</dc:date>
    </item>
  </channel>
</rss>

