<?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: &amp;quot;N/A&amp;quot; percentage in Single Value tile due to division by zero in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/quot-N-A-quot-percentage-in-Single-Value-tile-due-to-division-by/m-p/495409#M32451</link>
    <description>&lt;P&gt;Yes, my sample SPL changes how the percentage is calculated.  How exactly you should do it depends on your query.  Your &lt;CODE&gt;timechart&lt;/CODE&gt; command is not do the calculation, but you share the part of the query that is doing it then perhaps I can offer a better fix.&lt;/P&gt;</description>
    <pubDate>Fri, 08 May 2020 14:35:59 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2020-05-08T14:35:59Z</dc:date>
    <item>
      <title>"N/A" percentage in Single Value tile due to division by zero</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/quot-N-A-quot-percentage-in-Single-Value-tile-due-to-division-by/m-p/495406#M32448</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;

&lt;P&gt;I encountered a visualization issue in the Single Value tile on Splunk Enterprise 7 when the current value is greater than zero and the compared old value is zero: the displayed percentage change is displayed as "N/A" due to the division by 0 in the percentage ratio calculation (x/0 * 100).&lt;BR /&gt;
Even if the result is mathematically correct, displaying "N/A" makes the user think that something is not working as expected in Splunk or that some data are corrupted.&lt;/P&gt;

&lt;P&gt;The only workaround I found till now is replacing the 0 values with a little higher value between 0 and 0.1 (e.g. 0.001 or 0.999), but the displayed percentage is obviously ugly (e.g. 500000 for current value 5, when using 0,001 instead of 0).&lt;/P&gt;

&lt;P&gt;The query is just a count of some events, so, after the base search, it ends with "| timechart span=1h count by key".&lt;/P&gt;

&lt;P&gt;Have anyone a solution or a better workaround?&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
G.P.&lt;/P&gt;</description>
      <pubDate>Fri, 08 May 2020 13:57:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/quot-N-A-quot-percentage-in-Single-Value-tile-due-to-division-by/m-p/495406#M32448</guid>
      <dc:creator>gpugliese</dc:creator>
      <dc:date>2020-05-08T13:57:03Z</dc:date>
    </item>
    <item>
      <title>Re: "N/A" percentage in Single Value tile due to division by zero</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/quot-N-A-quot-percentage-in-Single-Value-tile-due-to-division-by/m-p/495407#M32449</link>
      <description>&lt;P&gt;"N/A" seems appropriate, but perhaps it doesn't fit your use case.  Consider detecting the divide-by-zero case in your query.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval pct = if(bar=0, 0, foo * 100 /bar)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 May 2020 14:06:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/quot-N-A-quot-percentage-in-Single-Value-tile-due-to-division-by/m-p/495407#M32449</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-05-08T14:06:57Z</dc:date>
    </item>
    <item>
      <title>Re: "N/A" percentage in Single Value tile due to division by zero</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/quot-N-A-quot-percentage-in-Single-Value-tile-due-to-division-by/m-p/495408#M32450</link>
      <description>&lt;P&gt;Hi richgalloway,&lt;BR /&gt;
thanks for the answer. I just updated the initial post with some additional details.&lt;BR /&gt;
My query ends with "| timechart span=1h count by key", because the tile displays the current amount of some filtered events and the percentage change compared to 7 days before. The value is often 0, so when the current value is more than 0 and the old one is 0, the percentage is "N/A".&lt;/P&gt;

&lt;P&gt;I guess that your suggestion is trying to replace the calculation of the percentage, isn't it?&lt;BR /&gt;
However, I think that I cannot change how it is calculated, just the data it uses, am I wrong?&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
G.P.&lt;/P&gt;</description>
      <pubDate>Fri, 08 May 2020 14:17:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/quot-N-A-quot-percentage-in-Single-Value-tile-due-to-division-by/m-p/495408#M32450</guid>
      <dc:creator>gpugliese</dc:creator>
      <dc:date>2020-05-08T14:17:23Z</dc:date>
    </item>
    <item>
      <title>Re: "N/A" percentage in Single Value tile due to division by zero</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/quot-N-A-quot-percentage-in-Single-Value-tile-due-to-division-by/m-p/495409#M32451</link>
      <description>&lt;P&gt;Yes, my sample SPL changes how the percentage is calculated.  How exactly you should do it depends on your query.  Your &lt;CODE&gt;timechart&lt;/CODE&gt; command is not do the calculation, but you share the part of the query that is doing it then perhaps I can offer a better fix.&lt;/P&gt;</description>
      <pubDate>Fri, 08 May 2020 14:35:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/quot-N-A-quot-percentage-in-Single-Value-tile-due-to-division-by/m-p/495409#M32451</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-05-08T14:35:59Z</dc:date>
    </item>
    <item>
      <title>Re: "N/A" percentage in Single Value tile due to division by zero</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/quot-N-A-quot-percentage-in-Single-Value-tile-due-to-division-by/m-p/495410#M32452</link>
      <description>&lt;P&gt;Ok, thanks. This is the simplest query among the ones with this issue:&lt;BR /&gt;
level="INFO"&lt;BR /&gt;
| timechart span=1h count&lt;/P&gt;

&lt;P&gt;I am not sure how to set the "eval" part you suggested, since I tried to change the foo and bar variables according to my count, but I have no reference to the 7-days-before in the search query: it is automatically calculated by Splunk when I choose "percent" and "7 days before" in the single value chart format menu.&lt;/P&gt;

&lt;P&gt;And this is a chart with the "N/A" issue:&lt;BR /&gt;
&lt;IMG src="https://i.postimg.cc/zDS1YP6c/chart.png" alt="chart" /&gt;&lt;BR /&gt;
Here another example, but with only more filters in the search (everything else is the same as above):&lt;BR /&gt;
&lt;IMG src="https://i.postimg.cc/qqgcwF3v/chart.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Mon, 11 May 2020 11:10:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/quot-N-A-quot-percentage-in-Single-Value-tile-due-to-division-by/m-p/495410#M32452</guid>
      <dc:creator>gpugliese</dc:creator>
      <dc:date>2020-05-11T11:10:32Z</dc:date>
    </item>
  </channel>
</rss>

