<?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: Eval command for a field to assign multi value fields in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-assign-a-field-values-of-two-different-fields/m-p/588366#M204907</link>
    <description>&lt;P&gt;coalesce should work as you have used it, however, this assume that the "missing" field is null, not just blank. You could try inserting&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval empID=if(empID="",null(),empID)&lt;/LI-CODE&gt;&lt;P&gt;Although if you are going to do the comparison, you could try&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval identity=if(isnull(empID) OR empID="",Non-empID,empID)&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 10 Mar 2022 09:04:23 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2022-03-10T09:04:23Z</dc:date>
    <item>
      <title>How to use eval to assign a field  values of two different fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-assign-a-field-values-of-two-different-fields/m-p/588358#M204905</link>
      <description>&lt;P&gt;Gentlemen,&lt;BR /&gt;How can i use eval&amp;nbsp; to assign a field&amp;nbsp; values of 2 different fields ?&lt;BR /&gt;&lt;BR /&gt;In my events, i have 2 fields:&amp;nbsp; empID and Non-empID .&amp;nbsp; I want eval to create a new field called &lt;STRONG&gt;identity&lt;/STRONG&gt;&amp;nbsp; and this should have the value of either empID OR Non-empID whichever is present .&amp;nbsp; Hope i am clear&lt;/P&gt;
&lt;P&gt;I tried&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;eval identity = coalesce (empID , Non-empID ) &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;&amp;nbsp;but this didn't work.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Any&amp;nbsp; suggestions ?&amp;nbsp; Any other way to get this done if eval doesn't do it ?&lt;BR /&gt;Eventually i am going to have a table as follows, and the Identity column should consolidate empID / Non-empID whichever is present for that employee record.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="25%" height="25px"&gt;identity&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;First&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;Last&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;email&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="25px"&gt;Emp ID&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="25px"&gt;Non-Emp ID&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2022 15:46:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-assign-a-field-values-of-two-different-fields/m-p/588358#M204905</guid>
      <dc:creator>neerajs_81</dc:creator>
      <dc:date>2022-03-10T15:46:46Z</dc:date>
    </item>
    <item>
      <title>Re: Eval command for a field to assign multi value fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-assign-a-field-values-of-two-different-fields/m-p/588363#M204906</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/229059"&gt;@neerajs_81&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;the minus sign "-" sometimes isn't recognized in Splunk field names, Sop I hint to avoid or rename it, in other words:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;your_search
| rename "Non-empID" as Non_empID
| eval identity=coalesce(empID,Non_empID ) &lt;/LI-CODE&gt;&lt;P&gt;but I don't understand if you want to take only one value or a multi value, as you said in the question title: using eval and coalesce, you have a single value field not a multi value, could you use some example to describe your need?&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2022 08:59:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-assign-a-field-values-of-two-different-fields/m-p/588363#M204906</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-03-10T08:59:09Z</dc:date>
    </item>
    <item>
      <title>Re: Eval command for a field to assign multi value fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-assign-a-field-values-of-two-different-fields/m-p/588366#M204907</link>
      <description>&lt;P&gt;coalesce should work as you have used it, however, this assume that the "missing" field is null, not just blank. You could try inserting&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval empID=if(empID="",null(),empID)&lt;/LI-CODE&gt;&lt;P&gt;Although if you are going to do the comparison, you could try&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval identity=if(isnull(empID) OR empID="",Non-empID,empID)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 10 Mar 2022 09:04:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-assign-a-field-values-of-two-different-fields/m-p/588366#M204907</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-03-10T09:04:23Z</dc:date>
    </item>
    <item>
      <title>Re: Eval command for a field to assign multi value fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-assign-a-field-values-of-two-different-fields/m-p/588368#M204908</link>
      <description>&lt;P&gt;Thank you for responding. Maybe wrong choice of words but here is my use case.&lt;BR /&gt;We have some users that either have a empID or Non-empID depending on their role.&amp;nbsp; Example:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="25%" height="25px"&gt;First&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;Last&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;empID&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;Non-empID&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="25px"&gt;John&amp;nbsp;&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;xx&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;1234&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="25px"&gt;Dave&lt;/TD&gt;&lt;TD height="25px"&gt;xxx&lt;/TD&gt;&lt;TD height="25px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD height="25px"&gt;3456&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;I need to merge/ consolidate both the ID values in a common field "&lt;STRONG&gt;identity&lt;/STRONG&gt;" which will be my unique identifier for that user.&amp;nbsp; So the final result should be like this"&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;First&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;Last&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;identity&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;John&amp;nbsp;&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;xx&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;1234&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;Dave&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;xxx&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;3456&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;Hope this helps ?&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2022 09:30:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-assign-a-field-values-of-two-different-fields/m-p/588368#M204908</guid>
      <dc:creator>neerajs_81</dc:creator>
      <dc:date>2022-03-10T09:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: Eval command for a field to assign multi value fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-assign-a-field-values-of-two-different-fields/m-p/588369#M204909</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp; thank you. In my case, the missing values are blank .&amp;nbsp; &amp;nbsp;Basically the folks who don't have either of ID have that value showing as blank &amp;lt;empty&amp;gt; when i output to a table.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2022 09:32:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-assign-a-field-values-of-two-different-fields/m-p/588369#M204909</guid>
      <dc:creator>neerajs_81</dc:creator>
      <dc:date>2022-03-10T09:32:54Z</dc:date>
    </item>
    <item>
      <title>Re: Eval command for a field to assign multi value fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-assign-a-field-values-of-two-different-fields/m-p/588375#M204912</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/229059"&gt;@neerajs_81&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;yes, the solution is the one of my previous answer: you have to use eval coalesce command :&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;your_search
| rename "Non-empID" AS Non_empID
| eval identity=coalesce(empID,Non_empID)
| stats values(First) AS First last(Last) As Last BY identity&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2022 09:53:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-assign-a-field-values-of-two-different-fields/m-p/588375#M204912</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-03-10T09:53:11Z</dc:date>
    </item>
    <item>
      <title>Re: Eval command for a field to assign multi value fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-assign-a-field-values-of-two-different-fields/m-p/588379#M204915</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/229059"&gt;@neerajs_81&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;good for you, see next time!&lt;/P&gt;&lt;P&gt;Ciao and happy splunking&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;P.S.: Karma Points are appreciated by all the Contributors &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2022 10:16:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-assign-a-field-values-of-two-different-fields/m-p/588379#M204915</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-03-10T10:16:01Z</dc:date>
    </item>
  </channel>
</rss>

