<?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: using a variable with eval in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/using-a-variable-with-eval/m-p/132482#M36144</link>
    <description>&lt;P&gt;It works!   Thanks for your help. &lt;/P&gt;</description>
    <pubDate>Fri, 19 Sep 2014 23:15:59 GMT</pubDate>
    <dc:creator>hcastell</dc:creator>
    <dc:date>2014-09-19T23:15:59Z</dc:date>
    <item>
      <title>using a variable with eval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/using-a-variable-with-eval/m-p/132479#M36141</link>
      <description>&lt;P&gt;Yet another Newbie question, I have the following search string that's working fine:&lt;/P&gt;

&lt;P&gt;| eval DOCSIS_TxPWR_Rdy=case(TestTxPwr=="n/a", "Fail", TestTxPwr &amp;lt; "57", "Pass", TestTxPwr &amp;gt;"57", "Fail") &lt;/P&gt;

&lt;P&gt;However, the value of TestTxPwr can be two different values dependent upon what type of hardware I'm using.  So I have added the following :&lt;/P&gt;

&lt;P&gt;First eval defines the generation of the Boxtype then I wanted to do &lt;BR /&gt;
| eval STB_Generation=case(BoxType="8642", "G6", BoxType="4642", "G6", BoxType="9865","G8") &lt;/P&gt;

&lt;P&gt;Then I set a variable with the associated value that needs to be used for TestTxPwr&lt;/P&gt;

&lt;P&gt;| eval stbGenSNRVAL=if(STB_Generation=="G6", 54, 57)&lt;/P&gt;

&lt;P&gt;What I am wrestling with is trying to figure out how to pass the value of stbGenSNRVAL to the original eval string in place of the integer values noted in my example.  So this would be something like:&lt;/P&gt;

&lt;P&gt;| eval DOCSIS_TxPWR_Rdy=case(TestTxPwr=="n/a", "Fail", TestTxPwr &amp;lt; %stbGenSNRVal%, "Pass", TestTxPwr &amp;gt;%stbGenSNRVal%, "Fail") &lt;/P&gt;

&lt;P&gt;I know the above doesn't work but wanted to see if there was a way to accomplish my goal.  I am certainly open to taking a completely different approach if there's a better way to do this.  Hope the question is clear. Thanks in advance for your help.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:38:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/using-a-variable-with-eval/m-p/132479#M36141</guid>
      <dc:creator>hcastell</dc:creator>
      <dc:date>2020-09-28T17:38:18Z</dc:date>
    </item>
    <item>
      <title>Re: using a variable with eval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/using-a-variable-with-eval/m-p/132480#M36142</link>
      <description>&lt;P&gt;unless I read the question wrong, eval creates a field which you can use directly without enclosing them within %. (like you did in the eval stbGenSNRVAL statement)&lt;/P&gt;</description>
      <pubDate>Fri, 19 Sep 2014 16:02:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/using-a-variable-with-eval/m-p/132480#M36142</guid>
      <dc:creator>sk314</dc:creator>
      <dc:date>2014-09-19T16:02:26Z</dc:date>
    </item>
    <item>
      <title>Re: using a variable with eval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/using-a-variable-with-eval/m-p/132481#M36143</link>
      <description>&lt;P&gt;I agree with sk314, you should not need the "%" surrounding the variables.  This:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval DOCSIS_TxPWR_Rdy=case(TestTxPwr=="n/a", "Fail", TestTxPwr &amp;lt; %stbGenSNRVal%, "Pass", TestTxPwr &amp;gt;%stbGenSNRVal%, "Fail")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Should be this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval DOCSIS_TxPWR_Rdy=case(TestTxPwr=="n/a", "Fail", TestTxPwr &amp;lt; stbGenSNRVal, "Pass", TestTxPwr &amp;gt; stbGenSNRVal , "Fail")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Sep 2014 16:28:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/using-a-variable-with-eval/m-p/132481#M36143</guid>
      <dc:creator>jimodonald</dc:creator>
      <dc:date>2014-09-19T16:28:58Z</dc:date>
    </item>
    <item>
      <title>Re: using a variable with eval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/using-a-variable-with-eval/m-p/132482#M36144</link>
      <description>&lt;P&gt;It works!   Thanks for your help. &lt;/P&gt;</description>
      <pubDate>Fri, 19 Sep 2014 23:15:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/using-a-variable-with-eval/m-p/132482#M36144</guid>
      <dc:creator>hcastell</dc:creator>
      <dc:date>2014-09-19T23:15:59Z</dc:date>
    </item>
  </channel>
</rss>

