<?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 Need help on why my eval if statement isn't working in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Need-help-on-why-my-eval-if-statement-isn-t-working/m-p/674661#M230934</link>
    <description>&lt;P&gt;Hello,&amp;nbsp; I've been researching this online for over a day and nothing seems to be working for me.&amp;nbsp; I have 2 EVAL IF statements that simply looks at the network.connectType field.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;| eval MOBILE=if(network.connectType="MOBILE","1","0")&lt;/P&gt;&lt;P&gt;| eval WIFI=if(network.connectType="WIFI","1","0")&lt;/P&gt;&lt;P&gt;I am in need of creating a table that would show the count of MOBILE, WIFI, TOTAL, by Branch.&lt;/P&gt;&lt;P&gt;i.e&amp;nbsp; Branch | Total | WIFI | MOBILE&lt;/P&gt;&lt;P&gt;I'm able to create the table, but the two evals always show the same counts as the Total count.&amp;nbsp; I can't figure out why I am doing wrong.&lt;/P&gt;&lt;P&gt;The search I am using is the following:&lt;/P&gt;&lt;P&gt;index=main "details.package"="com.siteone.mobilepro", "details.tag"="Connectivity Service", event=NoConnectivityEvent, "details.message.additionalInfo.NetworkAccessStatus"="None"&lt;BR /&gt;| fields network.connectType, event, userSettings.site&lt;BR /&gt;| eval MOBILE=if(network.connectType="MOBILE","1","0")&lt;BR /&gt;| eval WIFI=if(network.connectType="WIFI","1","0")&lt;BR /&gt;| stats values("userSettings.site") as Branch, count(event) as "Total Disconnects", count(MOBILE) as "Cellular Disconnects", count(WIFI) as "Wifi Disconnects" by "userSettings.site"&lt;BR /&gt;| table Branch, "Total Disconnects", "Wifi Disconnects", "Cellular Disconnects"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help on this would be awesome and much appreciated.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 18 Jan 2024 13:50:49 GMT</pubDate>
    <dc:creator>mninansplunk</dc:creator>
    <dc:date>2024-01-18T13:50:49Z</dc:date>
    <item>
      <title>Need help on why my eval if statement isn't working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-on-why-my-eval-if-statement-isn-t-working/m-p/674661#M230934</link>
      <description>&lt;P&gt;Hello,&amp;nbsp; I've been researching this online for over a day and nothing seems to be working for me.&amp;nbsp; I have 2 EVAL IF statements that simply looks at the network.connectType field.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;| eval MOBILE=if(network.connectType="MOBILE","1","0")&lt;/P&gt;&lt;P&gt;| eval WIFI=if(network.connectType="WIFI","1","0")&lt;/P&gt;&lt;P&gt;I am in need of creating a table that would show the count of MOBILE, WIFI, TOTAL, by Branch.&lt;/P&gt;&lt;P&gt;i.e&amp;nbsp; Branch | Total | WIFI | MOBILE&lt;/P&gt;&lt;P&gt;I'm able to create the table, but the two evals always show the same counts as the Total count.&amp;nbsp; I can't figure out why I am doing wrong.&lt;/P&gt;&lt;P&gt;The search I am using is the following:&lt;/P&gt;&lt;P&gt;index=main "details.package"="com.siteone.mobilepro", "details.tag"="Connectivity Service", event=NoConnectivityEvent, "details.message.additionalInfo.NetworkAccessStatus"="None"&lt;BR /&gt;| fields network.connectType, event, userSettings.site&lt;BR /&gt;| eval MOBILE=if(network.connectType="MOBILE","1","0")&lt;BR /&gt;| eval WIFI=if(network.connectType="WIFI","1","0")&lt;BR /&gt;| stats values("userSettings.site") as Branch, count(event) as "Total Disconnects", count(MOBILE) as "Cellular Disconnects", count(WIFI) as "Wifi Disconnects" by "userSettings.site"&lt;BR /&gt;| table Branch, "Total Disconnects", "Wifi Disconnects", "Cellular Disconnects"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help on this would be awesome and much appreciated.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2024 13:50:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-on-why-my-eval-if-statement-isn-t-working/m-p/674661#M230934</guid>
      <dc:creator>mninansplunk</dc:creator>
      <dc:date>2024-01-18T13:50:49Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on why my eval if statement isn't working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-on-why-my-eval-if-statement-isn-t-working/m-p/674662#M230935</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/237490"&gt;@mninansplunk&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;sometimes ields with dot insied don't work in eval, so you have two solutions:&lt;/P&gt;&lt;P&gt;use quotes:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval MOBILE=if("network.connectType"="MOBILE","1","0")
| eval WIFI=if("network.connectType"="WIFI","1","0")&lt;/LI-CODE&gt;&lt;P&gt;or use a rename before the eval:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rename network.connectType AS network_connectType
| eval MOBILE=if(network_connectType="MOBILE","1","0")
| eval WIFI=if(network_connectType="WIFI","1","0")&lt;/LI-CODE&gt;&lt;P&gt;I prefer the second solution.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2024 13:53:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-on-why-my-eval-if-statement-isn-t-working/m-p/674662#M230935</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2024-01-18T13:53:47Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on why my eval if statement isn't working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-on-why-my-eval-if-statement-isn-t-working/m-p/674663#M230936</link>
      <description>&lt;P&gt;count(MOBILE) and count(WIFI) are merely counting the instances where the field is present (not null). Since you have set them to either 1 or 0, they are always present. Either set them to 1 or null(), or use sum(MOBILE) and sum(WIFI) instead&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2024 13:55:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-on-why-my-eval-if-statement-isn-t-working/m-p/674663#M230936</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-01-18T13:55:59Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on why my eval if statement isn't working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-on-why-my-eval-if-statement-isn-t-working/m-p/674674#M230937</link>
      <description>&lt;P&gt;Awesome, that did the trick, thank you very much for the quick help!!!&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2024 14:25:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-on-why-my-eval-if-statement-isn-t-working/m-p/674674#M230937</guid>
      <dc:creator>mninansplunk</dc:creator>
      <dc:date>2024-01-18T14:25:34Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on why my eval if statement isn't working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-on-why-my-eval-if-statement-isn-t-working/m-p/674681#M230939</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/237490"&gt;@mninansplunk&lt;/a&gt;&amp;nbsp;,&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, 18 Jan 2024 14:49:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-on-why-my-eval-if-statement-isn-t-working/m-p/674681#M230939</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2024-01-18T14:49:23Z</dc:date>
    </item>
  </channel>
</rss>

