<?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: help on tostring function in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/help-on-tostring-function/m-p/457745#M171285</link>
    <description>&lt;P&gt;thanks a lot&lt;/P&gt;</description>
    <pubDate>Sun, 12 May 2019 08:40:45 GMT</pubDate>
    <dc:creator>jip31</dc:creator>
    <dc:date>2019-05-12T08:40:45Z</dc:date>
    <item>
      <title>help on tostring function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-tostring-function/m-p/457740#M171280</link>
      <description>&lt;P&gt;hello&lt;/P&gt;

&lt;P&gt;I am doing the distinct count below in my search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats dc(host) AS OnlineCount by Code 
| where Code = "Online"
| fields OnlineCount 
| appendpipe 
    [ stats count 
    | where count=0]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But I also need to add text after the distinct count&lt;BR /&gt;
So I am doing this after the distinct count but I have nothing&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval dc = if(dc== 0, "no host", tostring(dc) + " hosts")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;could you help me please??&lt;/P&gt;</description>
      <pubDate>Sun, 12 May 2019 05:10:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-tostring-function/m-p/457740#M171280</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2019-05-12T05:10:50Z</dc:date>
    </item>
    <item>
      <title>Re: help on tostring function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-tostring-function/m-p/457741#M171281</link>
      <description>&lt;P&gt;There is no field named dc which you are executing your eval on, try this:&lt;BR /&gt;
    | stats dc(host) AS OnlineCount by info| eval OnlineCount = if(OnlineCount == 0, "no host", tostring(OnlineCount) + " hosts")&lt;BR /&gt;
     | fields OnlineCount&lt;/P&gt;</description>
      <pubDate>Sun, 12 May 2019 07:23:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-tostring-function/m-p/457741#M171281</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2019-05-12T07:23:37Z</dc:date>
    </item>
    <item>
      <title>Re: help on tostring function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-tostring-function/m-p/457742#M171282</link>
      <description>&lt;P&gt;I think you need to put name as "dc" , instead of variable OnlineCount&lt;BR /&gt;
Also your code contains a NULL problem for "dc", so i've changed the last field to put value only if the &lt;CODE&gt;dc &amp;gt;0&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;So&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults
| eval hosts="myhost"
| eval Code="Online"
| fields hosts,Code
| stats dc(hosts) AS dc by Code 
 | where Code = "Online"
 | fields dc 
 | appendpipe 
     [ stats count 
     | where count=0]
 | eval dc = if(dc&amp;gt; 0, tostring(dc) + " hosts","no host")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 12 May 2019 08:00:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-tostring-function/m-p/457742#M171282</guid>
      <dc:creator>koshyk</dc:creator>
      <dc:date>2019-05-12T08:00:04Z</dc:date>
    </item>
    <item>
      <title>Re: help on tostring function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-tostring-function/m-p/457743#M171283</link>
      <description>&lt;P&gt;ok thanks!&lt;BR /&gt;
I forgotten "as onlinecount"......&lt;/P&gt;</description>
      <pubDate>Sun, 12 May 2019 08:39:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-tostring-function/m-p/457743#M171283</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2019-05-12T08:39:38Z</dc:date>
    </item>
    <item>
      <title>Re: help on tostring function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-tostring-function/m-p/457744#M171284</link>
      <description>&lt;P&gt;Also thanks to you but I can accept only one answer...&lt;/P&gt;</description>
      <pubDate>Sun, 12 May 2019 08:40:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-tostring-function/m-p/457744#M171284</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2019-05-12T08:40:20Z</dc:date>
    </item>
    <item>
      <title>Re: help on tostring function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-tostring-function/m-p/457745#M171285</link>
      <description>&lt;P&gt;thanks a lot&lt;/P&gt;</description>
      <pubDate>Sun, 12 May 2019 08:40:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-tostring-function/m-p/457745#M171285</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2019-05-12T08:40:45Z</dc:date>
    </item>
  </channel>
</rss>

