<?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 if function with 2 arguments in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Eval-if-function-with-2-arguments/m-p/134498#M36763</link>
    <description>&lt;P&gt;Resulting into something like this&lt;/P&gt;

&lt;P&gt;... | eval totalVolumeGB=if(totalVolumeGB=="0" &amp;amp;&amp;amp; index=summary_*,maxTotalDataSizeMB*23/1024,totalVolumeGB)&lt;/P&gt;

&lt;P&gt;... | eval totalVolumeGB=if(totalVolumeGB=="0" &amp;amp;&amp;amp; index!=summary_*,maxTotalDataSizeMB*10/1024,totalVolumeGB)&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 16:24:33 GMT</pubDate>
    <dc:creator>bleung93</dc:creator>
    <dc:date>2020-09-28T16:24:33Z</dc:date>
    <item>
      <title>Eval if function with 2 arguments</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-if-function-with-2-arguments/m-p/134497#M36762</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;... | eval totalVolumeGB=if(totalVolumeGB=="0",maxTotalDataSizeMB*23/1024,totalVolumeGB)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How would I add in another argument inside the if function?&lt;/P&gt;

&lt;P&gt;I want to apply the above search query in 2 different situations. By including &lt;CODE&gt;"index=summary_*"&lt;/CODE&gt; and &lt;CODE&gt;"index!=summary_*"&lt;/CODE&gt; essentially have 2 evals.&lt;/P&gt;

&lt;P&gt;I have already tried inserting the following&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;if(totalVolumeGB=="0" &amp;amp;&amp;amp; index=summary_*,maxTotalDataSizeMB*23/1024,totalVolumeGB)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but did not eval correctly. What are some options I can do?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Apr 2014 22:04:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-if-function-with-2-arguments/m-p/134497#M36762</guid>
      <dc:creator>bleung93</dc:creator>
      <dc:date>2014-04-16T22:04:06Z</dc:date>
    </item>
    <item>
      <title>Re: Eval if function with 2 arguments</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-if-function-with-2-arguments/m-p/134498#M36763</link>
      <description>&lt;P&gt;Resulting into something like this&lt;/P&gt;

&lt;P&gt;... | eval totalVolumeGB=if(totalVolumeGB=="0" &amp;amp;&amp;amp; index=summary_*,maxTotalDataSizeMB*23/1024,totalVolumeGB)&lt;/P&gt;

&lt;P&gt;... | eval totalVolumeGB=if(totalVolumeGB=="0" &amp;amp;&amp;amp; index!=summary_*,maxTotalDataSizeMB*10/1024,totalVolumeGB)&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:24:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-if-function-with-2-arguments/m-p/134498#M36763</guid>
      <dc:creator>bleung93</dc:creator>
      <dc:date>2020-09-28T16:24:33Z</dc:date>
    </item>
    <item>
      <title>Re: Eval if function with 2 arguments</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-if-function-with-2-arguments/m-p/134499#M36764</link>
      <description>&lt;P&gt;I tried following the template in &lt;A href="http://answers.splunk.com/answers/101356/and-in-if-statement" target="_blank"&gt;http://answers.splunk.com/answers/101356/and-in-if-statement&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;| eval totalVolumeGB=if((totalVolumeGB=="0")AND(index!=summary_&lt;EM&gt;),maxTotalDataSizeMB*10/1024,totalVolumeGB)&lt;BR /&gt;
| eval totalVolumeGB=if((totalVolumeGB=="0")AND(index==summary_&lt;/EM&gt;),maxTotalDataSizeMB*23/1024,totalVolumeGB)&lt;/P&gt;

&lt;P&gt;Got an error banner stating as below... &lt;BR /&gt;
"Error in 'eval' command: The expression is malformed. An unexpected character is reached at '),maxTotalDataSizeMB*10/1024,totalVolumeGB)'."&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:24:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-if-function-with-2-arguments/m-p/134499#M36764</guid>
      <dc:creator>bleung93</dc:creator>
      <dc:date>2020-09-28T16:24:35Z</dc:date>
    </item>
    <item>
      <title>Re: Eval if function with 2 arguments</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-if-function-with-2-arguments/m-p/134500#M36765</link>
      <description>&lt;P&gt;You cannot use the asterisk character like that, &lt;CODE&gt;eval&lt;/CODE&gt; interprets it as multiplication and complains about not finding the second factor. Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval totalVolumeGB = if(totalVolumeGB=="0" AND NOT match(index, "^summary_"), maxTotalDataSizeMB*23/1024, totalVolumeGB)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Apr 2014 22:53:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-if-function-with-2-arguments/m-p/134500#M36765</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-04-16T22:53:58Z</dc:date>
    </item>
    <item>
      <title>Re: Eval if function with 2 arguments</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-if-function-with-2-arguments/m-p/134501#M36766</link>
      <description>&lt;P&gt;This fixed it up. Thanks for the much needed help Martin.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Apr 2014 23:00:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-if-function-with-2-arguments/m-p/134501#M36766</guid>
      <dc:creator>bleung93</dc:creator>
      <dc:date>2014-04-16T23:00:28Z</dc:date>
    </item>
  </channel>
</rss>

