Hi Everyone-
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.
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.
In summary, I need to calculate the difference in time for each row and then average them all in the indicator.
I sort of went off the suggestions here 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!
Here is the code I have:
(Start Time and End Time are Both Date Field Types mm/dd/yyy, h:mm)
var startDate = Date($datapoint.START_TIME)
var endDate = Date($datapoint.END_TIME)
var flightTime= DateDiff(endDate, startDate, 'minutes')/60
if (!isEmpty($datapoint.START_TIME) && !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
},
}