<?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: Create an eval if when the results from stats are 0 in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Create-an-eval-if-when-the-results-from-stats-are-0/m-p/556059#M157891</link>
    <description>&lt;P&gt;So basically the initial eval function I did was overriding the fields with previous values, the ones that were already null were getting filled in by the fillnull which is fine in this moment. But when all of the fields were zero, no stats table would show at all. Just a no results found&lt;/P&gt;</description>
    <pubDate>Wed, 16 Jun 2021 22:22:09 GMT</pubDate>
    <dc:creator>ebs</dc:creator>
    <dc:date>2021-06-16T22:22:09Z</dc:date>
    <item>
      <title>Create an eval if when the results from stats are 0</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-an-eval-if-when-the-results-from-stats-are-0/m-p/555886#M157842</link>
      <description>&lt;P&gt;Is there a way, besides fillnull, to do an&amp;nbsp;&lt;EM&gt;eval if(averageResponse=0, 0.000)&lt;/EM&gt;?&lt;/P&gt;&lt;P&gt;Basically, I want to be able to have the stats table show a result of 0.000 for a field if the results after the stats field is 0 without using a fillnull field in the case where every defined field is equalling zero.&lt;/P&gt;&lt;P&gt;This is the base search:&lt;/P&gt;&lt;P&gt;| datamodel metric summariesonly=true search&lt;BR /&gt;| search "metric.date"=2021-06-11 | rename "metric.date" as date&lt;BR /&gt;| rename "metric.uri_path" as uri_path&lt;BR /&gt;| eval category=case(like(uri_path, "/as/%/resume/as/authorization.ping"), "highPriority", uri_path="/pf/heartbeat.ping", "unattended",&lt;BR /&gt;uri_path="/?REF=undefined", "lowPriority", uri_path="/header-logo.svg", "largePayload")&lt;BR /&gt;| rename "metric.response_time" as response_time&lt;BR /&gt;| stats avg(response_time) by category&lt;BR /&gt;| rename avg(response_time) as averageResponse&lt;BR /&gt;| eval averageResponse=round(averageResponse,3)&lt;BR /&gt;| transpose 0 header_field=category&lt;BR /&gt;| fillnull value=0.000 highPriority, lowPriority, largePayload, unattended&lt;BR /&gt;| eval _time="$date$"&lt;BR /&gt;| fields highPriority, lowPriority, largePayload, unattended, _time&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jun 2021 00:26:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-an-eval-if-when-the-results-from-stats-are-0/m-p/555886#M157842</guid>
      <dc:creator>ebs</dc:creator>
      <dc:date>2021-06-16T00:26:22Z</dc:date>
    </item>
    <item>
      <title>Re: Create an eval if when the results from stats are 0</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-an-eval-if-when-the-results-from-stats-are-0/m-p/555891#M157845</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/228215"&gt;@ebs&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Is there a way, besides fillnull, to do an&amp;nbsp;&lt;EM&gt;eval if(averageResponse=0, 0.000)&lt;/EM&gt;?&lt;/P&gt;&lt;P&gt;Basically, I want to be able to have the stats table show a result of 0.000 for a field if the results after the stats field is 0 without using a fillnull field in the case where every defined field is equalling zero.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;It is not clear what is &amp;nbsp;your expected &amp;nbsp;outcome. &amp;nbsp;If all fields equal zero, do you want the &amp;nbsp;stats table to show all 0.0000, or not show all 0.0000?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jun 2021 02:24:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-an-eval-if-when-the-results-from-stats-are-0/m-p/555891#M157845</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2021-06-16T02:24:46Z</dc:date>
    </item>
    <item>
      <title>Re: Create an eval if when the results from stats are 0</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-an-eval-if-when-the-results-from-stats-are-0/m-p/555898#M157848</link>
      <description>&lt;P&gt;I have a screen shot of what the stats field looks like in my post previous. I would want under every field it to say 0.000 if there are no results&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jun 2021 04:12:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-an-eval-if-when-the-results-from-stats-are-0/m-p/555898#M157848</guid>
      <dc:creator>ebs</dc:creator>
      <dc:date>2021-06-16T04:12:50Z</dc:date>
    </item>
    <item>
      <title>Re: Create an eval if when the results from stats are 0</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-an-eval-if-when-the-results-from-stats-are-0/m-p/555901#M157850</link>
      <description>&lt;P&gt;Maybe one more clarification: This exercise is &amp;nbsp;to transform any single digit "0" into a 5-digit decimal "0.0000", as opposed to insert "0.0000" where a value is absent (which is the use case for fillnull). &amp;nbsp;If this is correct, your question is already the answer. &amp;nbsp; I don't see why you cannot use it.&lt;/P&gt;&lt;P&gt;As an example, I use this to generate a sequence of digits between 0 and 2, then transform "0" into "0.0000" using the exact expression in your question:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults count=5
| eval value = random() % 3

| eval value = if(value  == 0, "0.0000", value)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="zeroformat.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/14642iBD7664A9A8FD9A43/image-size/large?v=v2&amp;amp;px=999" role="button" title="zeroformat.png" alt="zeroformat.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Wed, 16 Jun 2021 04:30:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-an-eval-if-when-the-results-from-stats-are-0/m-p/555901#M157850</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2021-06-16T04:30:41Z</dc:date>
    </item>
    <item>
      <title>Re: Create an eval if when the results from stats are 0</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-an-eval-if-when-the-results-from-stats-are-0/m-p/555903#M157851</link>
      <description>&lt;P&gt;My main issue is when there are no results there is not stats table, that's why I'm looking into doing an eval if statement&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jun 2021 04:47:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-an-eval-if-when-the-results-from-stats-are-0/m-p/555903#M157851</guid>
      <dc:creator>ebs</dc:creator>
      <dc:date>2021-06-16T04:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: Create an eval if when the results from stats are 0</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-an-eval-if-when-the-results-from-stats-are-0/m-p/555904#M157852</link>
      <description>&lt;P&gt;Works if I use your eval with the fillnull, thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jun 2021 04:52:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-an-eval-if-when-the-results-from-stats-are-0/m-p/555904#M157852</guid>
      <dc:creator>ebs</dc:creator>
      <dc:date>2021-06-16T04:52:53Z</dc:date>
    </item>
    <item>
      <title>Re: Create an eval if when the results from stats are 0</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-an-eval-if-when-the-results-from-stats-are-0/m-p/555908#M157853</link>
      <description>&lt;P&gt;I'm finding it overwrites fields with values as well, I only want the if statement to apply to fields where the value is 0&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jun 2021 05:07:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-an-eval-if-when-the-results-from-stats-are-0/m-p/555908#M157853</guid>
      <dc:creator>ebs</dc:creator>
      <dc:date>2021-06-16T05:07:38Z</dc:date>
    </item>
    <item>
      <title>Re: Create an eval if when the results from stats are 0</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-an-eval-if-when-the-results-from-stats-are-0/m-p/555911#M157854</link>
      <description>&lt;P&gt;Fixed that, my issue. But now it won't produce the stats table anyway when there are no results at all&lt;/P&gt;&lt;P&gt;Search:&lt;/P&gt;&lt;P&gt;| datamodel metric summariesonly=true search&lt;BR /&gt;| search "metric.date"=2021-06-11&lt;BR /&gt;| rename "metric.date" as date&lt;BR /&gt;| rename "metric.uri_path" as uri_path&lt;BR /&gt;| eval category=case(like(uri_path, "/url1"), "highPriority", uri_path="/url2", "unattended",&lt;BR /&gt;uri_path="/url3", "lowPriority", uri_path="/url4", "largePayload")&lt;BR /&gt;| rename "metric.response_time" as response_time&lt;BR /&gt;| stats avg(response_time) by category&lt;BR /&gt;| rename avg(response_time) as averageResponse&lt;BR /&gt;| eval averageResponse = if(averageResponse == 0, "0.000", averageResponse)&lt;BR /&gt;| eval averageResponse=round(averageResponse,3)&lt;BR /&gt;| transpose 0 header_field=category&lt;BR /&gt;| fillnull value=0.000 highPriority, lowPriority, largePayload, unattended&lt;BR /&gt;| eval _time="$date$"&lt;BR /&gt;| fields highPriority, lowPriority, largePayload, unattended, _time&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jun 2021 05:14:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-an-eval-if-when-the-results-from-stats-are-0/m-p/555911#M157854</guid>
      <dc:creator>ebs</dc:creator>
      <dc:date>2021-06-16T05:14:34Z</dc:date>
    </item>
    <item>
      <title>Re: Create an eval if when the results from stats are 0</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-an-eval-if-when-the-results-from-stats-are-0/m-p/556014#M157874</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/228215"&gt;@ebs&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Fixed that, my issue. But now it won't produce the stats table anyway when there are no results at all&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;To make certain &amp;nbsp;of the situation: A &amp;nbsp;previous search made some false zeros (0); now that you fixed the search, those results become absent (null). &amp;nbsp; As a consequence, the stats table won't show &amp;nbsp;results. &amp;nbsp;Is this correct?&lt;/P&gt;&lt;P&gt;If that is the case (which differs from the title statement), handling all nulls in a timeseries is a common annoyance. &amp;nbsp;I had asked for help several &amp;nbsp;times before, and there have been several recent posts about this. &amp;nbsp;The most recent, and a rather efficient one, is offered by&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;in&amp;nbsp;&lt;A href="https://community.splunk.com/t5/Splunk-Search/Need-to-generate-0-results-in-case-of-no-data-available/m-p/555876/highlight/true#M157840" target="_blank"&gt;https://community.splunk.com/t5/Splunk-Search/Need-to-generate-0-results-in-case-of-no-data-available/m-p/555876/highlight/true#M157840&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jun 2021 15:49:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-an-eval-if-when-the-results-from-stats-are-0/m-p/556014#M157874</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2021-06-16T15:49:54Z</dc:date>
    </item>
    <item>
      <title>Re: Create an eval if when the results from stats are 0</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-an-eval-if-when-the-results-from-stats-are-0/m-p/556059#M157891</link>
      <description>&lt;P&gt;So basically the initial eval function I did was overriding the fields with previous values, the ones that were already null were getting filled in by the fillnull which is fine in this moment. But when all of the fields were zero, no stats table would show at all. Just a no results found&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jun 2021 22:22:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-an-eval-if-when-the-results-from-stats-are-0/m-p/556059#M157891</guid>
      <dc:creator>ebs</dc:creator>
      <dc:date>2021-06-16T22:22:09Z</dc:date>
    </item>
  </channel>
</rss>

