<?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: Assign value to multiple fields in an event based on single if condition in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Assign-value-to-multiple-fields-in-an-event-based-on-single-if/m-p/560473#M159283</link>
    <description>&lt;P&gt;Is there a direct relationship between the fields e.g. would something like&lt;/P&gt;&lt;P&gt;eval *1=if(condition, *2, *1)&lt;/P&gt;&lt;P&gt;make sense? If so, use foreach (it doesn't stop the multiple evaluations of the condition but at least you only have to write it once).&lt;/P&gt;&lt;P&gt;Is this issue that the condition is complex and you don't want to evaluate it multiple times? If so, would something like&lt;/P&gt;&lt;P&gt;eval set=if(complexcondition,1,0)&lt;/P&gt;&lt;P&gt;eval A1=If(set=1,A2,A1)&lt;/P&gt;&lt;P&gt;etc.&lt;/P&gt;&lt;P&gt;make sense?&lt;/P&gt;&lt;P&gt;Can you combine A1, B1, C1 into a multi-value field and A2, B2, C2 into another mv field and the assign one mv field to the other based on the condition?&lt;/P&gt;</description>
    <pubDate>Thu, 22 Jul 2021 13:41:17 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2021-07-22T13:41:17Z</dc:date>
    <item>
      <title>Assign value to multiple fields in an event based on single if condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Assign-value-to-multiple-fields-in-an-event-based-on-single-if/m-p/560468#M159280</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have an use case where I have an if condition involving multiple comparisons. Based on its outcome, I&amp;nbsp; want to re-assign values in multiple fields. Consider below example:&lt;/P&gt;&lt;P&gt;My fields are: A1, B1, C1, A2, B2, C2 and few other fields&lt;/P&gt;&lt;P&gt;I have an if condition and when it is true to assign value as below and if false do nothing:&lt;/P&gt;&lt;P&gt;A1=A2&lt;/P&gt;&lt;P&gt;B1=B2&lt;/P&gt;&lt;P&gt;C1=C2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now my query is, right now if I want to do this, I would have to write 3 different eval commands like below doing exact same comparisons:&lt;/P&gt;&lt;P&gt;| eval A1=if(&amp;lt;condition&amp;gt;, A2, A1)&amp;nbsp;&lt;/P&gt;&lt;P&gt;| eval B1=if(&amp;lt;condition&amp;gt;, B2, B1)&amp;nbsp;&lt;/P&gt;&lt;P&gt;| eval C1=if(&amp;lt;condition&amp;gt;, C2, C1)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way so that if I only use if once and when true, all three fields would get assigned value in one go. If there is a way, in terms of performance is above still better, I would be running this for more than hundred thousand records ?&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jul 2021 13:02:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Assign-value-to-multiple-fields-in-an-event-based-on-single-if/m-p/560468#M159280</guid>
      <dc:creator>payl_chdhry</dc:creator>
      <dc:date>2021-07-22T13:02:00Z</dc:date>
    </item>
    <item>
      <title>Re: Assign value to multiple fields in an event based on single if condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Assign-value-to-multiple-fields-in-an-event-based-on-single-if/m-p/560473#M159283</link>
      <description>&lt;P&gt;Is there a direct relationship between the fields e.g. would something like&lt;/P&gt;&lt;P&gt;eval *1=if(condition, *2, *1)&lt;/P&gt;&lt;P&gt;make sense? If so, use foreach (it doesn't stop the multiple evaluations of the condition but at least you only have to write it once).&lt;/P&gt;&lt;P&gt;Is this issue that the condition is complex and you don't want to evaluate it multiple times? If so, would something like&lt;/P&gt;&lt;P&gt;eval set=if(complexcondition,1,0)&lt;/P&gt;&lt;P&gt;eval A1=If(set=1,A2,A1)&lt;/P&gt;&lt;P&gt;etc.&lt;/P&gt;&lt;P&gt;make sense?&lt;/P&gt;&lt;P&gt;Can you combine A1, B1, C1 into a multi-value field and A2, B2, C2 into another mv field and the assign one mv field to the other based on the condition?&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jul 2021 13:41:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Assign-value-to-multiple-fields-in-an-event-based-on-single-if/m-p/560473#M159283</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-07-22T13:41:17Z</dc:date>
    </item>
  </channel>
</rss>

