<?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: Expression for custom lookup table values in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Expression-for-custom-lookup-table-values/m-p/672804#M230421</link>
    <description>&lt;P&gt;I think doing something like this would work.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;base_search&amp;gt;
    | lookup &amp;lt;lookup_name&amp;gt; UserID OUTPUT Attribute
    | eval
        attribute_regex=".*\-(\d+)\-.*",
        max_attribute=case(
            isnull(Attribute), null(),
            mvcount(Attribute)==1, max(tonumber(replace(Attribute, attribute_regex, "\1"))),
            mvcount(Attribute)&amp;gt;1, max(mvmap(Attribute, tonumber(replace(Attribute, attribute_regex, "\1"))))
            ),
        max_attribute_full=mvdedup(
            case(
                isnull(Attribute), null(),
                mvcount(Attribute)==1, if(tonumber(replace(Attribute, attribute_regex, "\1"))=='max_attribute', 'Attribute', null()),
                mvcount(Attribute)&amp;gt;1, mvmap(Attribute, if(tonumber(replace(Attribute, attribute_regex, "\1"))=='max_attribute', 'Attribute', null()))
                )
            )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;You can see in the screenshot below I used simulated data to do what I think you are asking for.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dtburrows3_0-1703717237716.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28675i6AF4202C8626CDA4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dtburrows3_0-1703717237716.png" alt="dtburrows3_0-1703717237716.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The regex used in the replace command can be adjusted to fit the pattern that is stored in the Attribute field value to just grab the number.&lt;/P&gt;</description>
    <pubDate>Wed, 27 Dec 2023 22:47:31 GMT</pubDate>
    <dc:creator>dtburrows3</dc:creator>
    <dc:date>2023-12-27T22:47:31Z</dc:date>
    <item>
      <title>Expression for custom lookup table values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Expression-for-custom-lookup-table-values/m-p/672801#M230419</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;This may be a bit of a peculiar question, but I'm trying to figure out if there's a way to use a certain expression in a search query to pull a "maximum" value based upon a custom table (.csv import) that is pulled into the query via the "lookup" command.&lt;/P&gt;&lt;P&gt;The table has 4 possible "Attribute" values which range from "level-1-access" to "level-4-access". In the stats table, a given UserID may have activity that reflect 1 or more of these (thus, a maximum of 4 per UserID).&lt;/P&gt;&lt;P&gt;Below is a sample dataset. What I'm attempting to do is filter this data so that it's only showing the "maximum" (or, "highest") value for each UserID. The rows &lt;FONT color="#339966"&gt;&lt;STRONG&gt;bolded in green&lt;/STRONG&gt;&lt;/FONT&gt; is what I'd want to see, with everything else excluded; thus, there should only be 1 row per distinct UserID.&lt;/P&gt;&lt;P&gt;One possible thought that comes to mind is adding an numeric field to the .csv lookup, though still not 100% certain how to go about rendering the stats table to only include the highest value per UserID.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated. Thanks!&amp;nbsp;&lt;/P&gt;&lt;TABLE width="243"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="101.625px" height="25px"&gt;&lt;STRONG&gt;UserID&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="140.375px" height="25px"&gt;&lt;STRONG&gt;Attribute&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="101.625px" height="25px"&gt;jdoe&lt;/TD&gt;&lt;TD width="140.375px" height="25px"&gt;level-1-access&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="101.625px" height="25px"&gt;jdoe&lt;/TD&gt;&lt;TD width="140.375px" height="25px"&gt;level-3-access&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="101.625px" height="25px"&gt;&lt;STRONG&gt;&lt;FONT color="#339966"&gt;jdoe&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="140.375px" height="25px"&gt;&lt;STRONG&gt;&lt;FONT color="#339966"&gt;level-4-access&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="101.625px" height="25px"&gt;asmith&lt;/TD&gt;&lt;TD width="140.375px" height="25px"&gt;level-1-access&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="101.625px" height="25px"&gt;&lt;FONT color="#339966"&gt;&lt;STRONG&gt;asmith&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;TD width="140.375px" height="25px"&gt;&lt;FONT color="#339966"&gt;&lt;STRONG&gt;level-2-access&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="101.625px" height="25px"&gt;ejones&lt;/TD&gt;&lt;TD width="140.375px" height="25px"&gt;level-3-access&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="101.625px" height="25px"&gt;&lt;FONT color="#339966"&gt;&lt;STRONG&gt;ejones&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;TD width="140.375px" height="25px"&gt;&lt;FONT color="#339966"&gt;&lt;STRONG&gt;level-4-access&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="101.625px" height="25px"&gt;pthomas&lt;/TD&gt;&lt;TD width="140.375px" height="25px"&gt;level-1-access&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="101.625px" height="25px"&gt;pthomas&lt;/TD&gt;&lt;TD width="140.375px" height="25px"&gt;level-2-access&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="101.625px" height="25px"&gt;pthomas&lt;/TD&gt;&lt;TD width="140.375px" height="25px"&gt;level-3-access&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="101.625px" height="25px"&gt;&lt;STRONG&gt;&lt;FONT color="#339966"&gt;pthomas&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="140.375px" height="25px"&gt;&lt;STRONG&gt;&lt;FONT color="#339966"&gt;level-4-access&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Wed, 27 Dec 2023 21:43:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Expression-for-custom-lookup-table-values/m-p/672801#M230419</guid>
      <dc:creator>bcanfield83</dc:creator>
      <dc:date>2023-12-27T21:43:47Z</dc:date>
    </item>
    <item>
      <title>Re: Expression for custom lookup table values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Expression-for-custom-lookup-table-values/m-p/672804#M230421</link>
      <description>&lt;P&gt;I think doing something like this would work.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;base_search&amp;gt;
    | lookup &amp;lt;lookup_name&amp;gt; UserID OUTPUT Attribute
    | eval
        attribute_regex=".*\-(\d+)\-.*",
        max_attribute=case(
            isnull(Attribute), null(),
            mvcount(Attribute)==1, max(tonumber(replace(Attribute, attribute_regex, "\1"))),
            mvcount(Attribute)&amp;gt;1, max(mvmap(Attribute, tonumber(replace(Attribute, attribute_regex, "\1"))))
            ),
        max_attribute_full=mvdedup(
            case(
                isnull(Attribute), null(),
                mvcount(Attribute)==1, if(tonumber(replace(Attribute, attribute_regex, "\1"))=='max_attribute', 'Attribute', null()),
                mvcount(Attribute)&amp;gt;1, mvmap(Attribute, if(tonumber(replace(Attribute, attribute_regex, "\1"))=='max_attribute', 'Attribute', null()))
                )
            )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;You can see in the screenshot below I used simulated data to do what I think you are asking for.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dtburrows3_0-1703717237716.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28675i6AF4202C8626CDA4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dtburrows3_0-1703717237716.png" alt="dtburrows3_0-1703717237716.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The regex used in the replace command can be adjusted to fit the pattern that is stored in the Attribute field value to just grab the number.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2023 22:47:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Expression-for-custom-lookup-table-values/m-p/672804#M230421</guid>
      <dc:creator>dtburrows3</dc:creator>
      <dc:date>2023-12-27T22:47:31Z</dc:date>
    </item>
    <item>
      <title>Re: Expression for custom lookup table values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Expression-for-custom-lookup-table-values/m-p/672889#M230444</link>
      <description>&lt;P&gt;Thank you very much!!!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Dec 2023 19:03:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Expression-for-custom-lookup-table-values/m-p/672889#M230444</guid>
      <dc:creator>bcanfield83</dc:creator>
      <dc:date>2023-12-29T19:03:58Z</dc:date>
    </item>
  </channel>
</rss>

