<?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: Arcade line to remove NaN value in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-line-to-remove-nan-value/m-p/1388991#M9172</link>
    <description>&lt;P&gt;You can wrap the whole expression in an &lt;STRONG&gt;Iif &lt;/STRONG&gt;function, and return something else when there's no value. And you can actual build the entire text string in the expression as well.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var Off = $datapoint.DateOff
var On  = $datapoint.DateRelightComplete

var HoursOff = Iif(
  IsEmpty(Off), // check if field is empty
  'System Never Turned Off',
  `(${Round(DateDiff(On, Off, 'hours'), 1)} Hours without Gas)`
)

return {
  attributes: { HoursOff }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then your line item template can just be &lt;STRONG&gt;{expression/HoursOff} &lt;/STRONG&gt;.&lt;/P&gt;</description>
    <pubDate>Thu, 29 Feb 2024 18:14:01 GMT</pubDate>
    <dc:creator>jcarlson</dc:creator>
    <dc:date>2024-02-29T18:14:01Z</dc:date>
    <item>
      <title>Arcade line to remove NaN value</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-line-to-remove-nan-value/m-p/1388975#M9170</link>
      <description>&lt;P&gt;This maybe a simple snippet, but I cannot get it to work. I have a small arcade line on my dashboard list to calculate the time that gas was turned off. Simpily subtracts the On time from the Off time.&amp;nbsp;&lt;/P&gt;&lt;P&gt;But, when a service is never turned off, it has nothing in these fields to subtract and results in a 'NaN' I wanted to add an iif statement that takes these NaN's and either leaves them blank and displays nothing or more ideally comes back with 'Zero'&lt;/P&gt;&lt;P&gt;But since it is a NaN result and not something that I can add an If Blank, I am struggling to figure out how this can be done.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Any help would be amazing! Thanks.&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Attached: List view from dashboard and the snippet of the arcade&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Arcade Text:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;var Status = $datapoint.OutageStatus&lt;BR /&gt;var Off = $datapoint.DateOff&lt;BR /&gt;var On = $datapoint.DateRelightComplete&lt;BR /&gt;var DaysOff = DateDiff (On, Off, 'hours')&lt;BR /&gt;var HoursOff = Round(DaysOff,1)&lt;/P&gt;&lt;P&gt;return {&lt;BR /&gt;textColor: '',&lt;BR /&gt;backgroundColor: '',&lt;BR /&gt;separatorColor:'',&lt;BR /&gt;selectionColor: '',&lt;BR /&gt;selectionTextColor: '',&lt;BR /&gt;attributes: {&lt;BR /&gt;HoursOff:HoursOff,&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Line item template:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;({expression/HoursOff} Hours without Gas)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Feb 2024 17:54:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-line-to-remove-nan-value/m-p/1388975#M9170</guid>
      <dc:creator>APBlough</dc:creator>
      <dc:date>2024-02-29T17:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade line to remove NaN value</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-line-to-remove-nan-value/m-p/1388988#M9171</link>
      <description>&lt;P&gt;You can check if those values are empty before doing your calculations&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var Status = $datapoint.OutageStatus;
var Off = $datapoint.DateOff;
var On = $datapoint.DateRelightComplete;
var HoursOff;
if (IsEmpty(On) || IsEmtpy(Off)) {
  HoursOff = 0;
} else {
  HoursOff = Round(DateDiff(On, Off, 'hours'), 1);
}

return {
  textColor: '',
  backgroundColor: '',
  separatorColor:'',
  selectionColor: '',
  selectionTextColor: '',
  attributes: {
    HoursOff:HoursOff,
  }
}&lt;/LI-CODE&gt;&lt;P&gt;or you can use the &lt;A href="https://developers.arcgis.com/arcade/function-reference/logical_functions/#isnan" target="_self"&gt;IsNan&lt;/A&gt; function afterward&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var Status = $datapoint.OutageStatus
var Off = $datapoint.DateOff
var On = $datapoint.DateRelightComplete
var DaysOff = DateDiff (On, Off, 'hours')
var HoursOff = Round(DaysOff,1)
if (IsNan(HoursOff)) HoursOff = 0;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Feb 2024 18:21:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-line-to-remove-nan-value/m-p/1388988#M9171</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2024-02-29T18:21:14Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade line to remove NaN value</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-line-to-remove-nan-value/m-p/1388991#M9172</link>
      <description>&lt;P&gt;You can wrap the whole expression in an &lt;STRONG&gt;Iif &lt;/STRONG&gt;function, and return something else when there's no value. And you can actual build the entire text string in the expression as well.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var Off = $datapoint.DateOff
var On  = $datapoint.DateRelightComplete

var HoursOff = Iif(
  IsEmpty(Off), // check if field is empty
  'System Never Turned Off',
  `(${Round(DateDiff(On, Off, 'hours'), 1)} Hours without Gas)`
)

return {
  attributes: { HoursOff }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then your line item template can just be &lt;STRONG&gt;{expression/HoursOff} &lt;/STRONG&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Feb 2024 18:14:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-line-to-remove-nan-value/m-p/1388991#M9172</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2024-02-29T18:14:01Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade line to remove NaN value</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-line-to-remove-nan-value/m-p/1388995#M9173</link>
      <description>&lt;P&gt;That's perfect! I was trying to get the iif statement in the wrong spot. This also helps me understand how to simplify my arcade formatting. Thank you so much for the help!&lt;/P&gt;</description>
      <pubDate>Thu, 29 Feb 2024 18:19:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-line-to-remove-nan-value/m-p/1388995#M9173</guid>
      <dc:creator>APBlough</dc:creator>
      <dc:date>2024-02-29T18:19:17Z</dc:date>
    </item>
  </channel>
</rss>

