<?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: Display Average Flight Time in Indicator in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/display-average-flight-time-in-indicator/m-p/1458755#M9582</link>
    <description>&lt;P&gt;Awesome&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2839"&gt;@KenBuja&lt;/a&gt;! I have added the script you supplied above, I am very grateful. I am getting an error in the second part that I cannot figure out.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have added our portal and the Feature id, those are the only changes I have made.&amp;nbsp;&lt;/P&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="JustinH_0-1715614951895.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/103939i8441DECEE2CC42DB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JustinH_0-1715614951895.png" alt="JustinH_0-1715614951895.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 13 May 2024 15:43:17 GMT</pubDate>
    <dc:creator>JustinH</dc:creator>
    <dc:date>2024-05-13T15:43:17Z</dc:date>
    <item>
      <title>Display Average Flight Time in Indicator</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/display-average-flight-time-in-indicator/m-p/1423363#M9561</link>
      <description>&lt;P&gt;Hi Everyone-&amp;nbsp;&lt;/P&gt;&lt;P&gt;We are trying to display the average flight time for our drone program inside of an indicator. We have two fields, startTime and endTime. We could easily make this calculation in a new field but when we get the data pushed to AGOL via a third party, all of the data is overwritten. Since the fields stay the same, if we are able to calculate this in an indicator that would be helpful.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get the script to work but only when I use a Feature value type. When I choose a statistic value type the indicator widget hides my date fields.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In summary, I need to calculate the difference in time for each row and then average them all in the indicator.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I sort of went off the suggestions&amp;nbsp;&lt;A href="https://www.esri.com/arcgis-blog/products/ops-dashboard/real-time/displaying-time-spans-with-arcade-in-dashboards/" target="_self"&gt;here&lt;/A&gt;&amp;nbsp;but they focus on using this in a list instead of an indicator. However, it is important to note that the article says we could do the same thing in an indicator!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code I have:&amp;nbsp;&lt;/P&gt;&lt;P&gt;(Start Time and End Time are Both Date Field Types mm/dd/yyy, h:mm)&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var startDate = Date($datapoint.START_TIME)
var endDate = Date($datapoint.END_TIME)
var flightTime= DateDiff(endDate, startDate, 'minutes')/60
if (!isEmpty($datapoint.START_TIME) &amp;amp;&amp;amp; !isEmpty($datapoint.END_TIME))
return flightTime

return {
  //textColor:'',
  //backgroundColor:'',
  //topText: '',
  //topTextColor: '',
  //topTextOutlineColor: '',
  //topTextMaxSize: 'medium',
  middleText:'',
  middleTextColor: '',
  middleTextOutlineColor: '',
  middleTextMaxSize: 'large',
  //bottomText: '',
  //bottomTextColor: '',
  //bottomTextOutlineColor: '',
  //bottomTextMaxSize: 'medium',
  //iconName:'',
  //iconAlign:'left',
  //iconColor:'',
  //iconOutlineColor:'',
  //noValue:false,
  attributes: {
    flightTime:flightTime
  },
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2024 16:23:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/display-average-flight-time-in-indicator/m-p/1423363#M9561</guid>
      <dc:creator>JustinH</dc:creator>
      <dc:date>2024-05-09T16:23:39Z</dc:date>
    </item>
    <item>
      <title>Re: Display Average Flight Time in Indicator</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/display-average-flight-time-in-indicator/m-p/1423984#M9562</link>
      <description>&lt;P&gt;If you want to get the average time for all the flights, then you'll want to create a FeatureSet to be used in the indicator&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var p = Portal("https://arcgis.com");
var fs = FeatureSetByPortalItem(p, 'itemId', 0);

var cumulative_flight_time = 0;
var counter = 0;
for (var f in fs) {
  var startDate = Date(f.START_TIME)
  var endDate = Date(f.END_TIME)
  var flightTime = DateDiff(endDate, startDate, 'minutes')/60
  cumulative_flight_time += flightTime;
  counter++;
}

var theDict = { 
  'fields': [{ 'name': 'ave_flight_time', 'type': esriFieldTypeDouble'}], 
  'geometryType': '', 
  'features': [
    { 
      'attributes': { 
        'ave_flight_time': cumulative_flight_time / counter
      }
    }
  ]
}; 

return FeatureSet(theDict); &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2024 17:55:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/display-average-flight-time-in-indicator/m-p/1423984#M9562</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2024-05-09T17:55:17Z</dc:date>
    </item>
    <item>
      <title>Re: Display Average Flight Time in Indicator</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/display-average-flight-time-in-indicator/m-p/1424564#M9563</link>
      <description>&lt;P&gt;This is great, thanks! I am assuming I would call on this feature set in the template "middleText"? I understand what your code is doing (extremely helpful). I guess I am trying to figure out what to do with it next!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Very appreciated!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2024 19:24:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/display-average-flight-time-in-indicator/m-p/1424564#M9563</guid>
      <dc:creator>JustinH</dc:creator>
      <dc:date>2024-05-09T19:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: Display Average Flight Time in Indicator</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/display-average-flight-time-in-indicator/m-p/1424746#M9565</link>
      <description>&lt;P&gt;No, this will be the data source of the indicator. In the Settings window, click the Change button for the Layer and create a new data expression.&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2024 19:46:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/display-average-flight-time-in-indicator/m-p/1424746#M9565</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2024-05-09T19:46:31Z</dc:date>
    </item>
    <item>
      <title>Re: Display Average Flight Time in Indicator</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/display-average-flight-time-in-indicator/m-p/1458755#M9582</link>
      <description>&lt;P&gt;Awesome&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2839"&gt;@KenBuja&lt;/a&gt;! I have added the script you supplied above, I am very grateful. I am getting an error in the second part that I cannot figure out.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have added our portal and the Feature id, those are the only changes I have made.&amp;nbsp;&lt;/P&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="JustinH_0-1715614951895.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/103939i8441DECEE2CC42DB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JustinH_0-1715614951895.png" alt="JustinH_0-1715614951895.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2024 15:43:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/display-average-flight-time-in-indicator/m-p/1458755#M9582</guid>
      <dc:creator>JustinH</dc:creator>
      <dc:date>2024-05-13T15:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: Display Average Flight Time in Indicator</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/display-average-flight-time-in-indicator/m-p/1459019#M9583</link>
      <description>&lt;P&gt;Sorry...I left out a quotation mark on line 15&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  'fields': [{ 'name': 'ave_flight_time', 'type': 'esriFieldTypeDouble'}], &lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 13 May 2024 16:24:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/display-average-flight-time-in-indicator/m-p/1459019#M9583</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2024-05-13T16:24:44Z</dc:date>
    </item>
    <item>
      <title>Re: Display Average Flight Time in Indicator</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/display-average-flight-time-in-indicator/m-p/1460622#M9584</link>
      <description>&lt;P&gt;Thanks so much! It worked!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2024 20:28:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/display-average-flight-time-in-indicator/m-p/1460622#M9584</guid>
      <dc:creator>JustinH</dc:creator>
      <dc:date>2024-05-13T20:28:41Z</dc:date>
    </item>
  </channel>
</rss>

