Arcade Script To Calculate Response Time From 2 Date Columns

415
2
Jump to solution
12-20-2023 07:19 AM
MarkKlein
New Contributor

Hello All!  My first post to the Community so I hope I include the correct information to assist with my question!

I have been tasked with creating a dashboard for our calls for service and have no experience with Arcade.  I would like to calculate our average response times from when our car gets the dispatch (FirstDispatchTime) until they arrive (FirstArrive), eliminating null entries in the calculation.  A portion of the data export is below:

MarkKlein_0-1703082605329.png

All of the 'Seconds2' columns are internally calculated using the 'CallTime' column so that does not really reflect our departments response time as we have no control over how long dispatch holds the call.

Ideally, I would like the displayed result shown as 'mm:ss' on the dashboard indicator.

Any script suggestion would be greatly appreciated!

Thank You!

Mark Klein 

 

 

 

 

0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

Arcade has a function, DateDiff. Give it two date fields and specify the units, and it will return the value.

DateDiff($feature['FirstArrive'], $feature['FirstDispatchTime'], 'minutes')

You can use that to calcualte a new field in the data itself, or you could use it in the Dashboard to show the response time.

If you can't include it as a field calculation, you will want to look into creating a Data Expression, but that's a bit more advanced if you've never used Arcade. Is calculating the field an option?

- Josh Carlson
Kendall County GIS

View solution in original post

2 Replies
jcarlson
MVP Esteemed Contributor

Arcade has a function, DateDiff. Give it two date fields and specify the units, and it will return the value.

DateDiff($feature['FirstArrive'], $feature['FirstDispatchTime'], 'minutes')

You can use that to calcualte a new field in the data itself, or you could use it in the Dashboard to show the response time.

If you can't include it as a field calculation, you will want to look into creating a Data Expression, but that's a bit more advanced if you've never used Arcade. Is calculating the field an option?

- Josh Carlson
Kendall County GIS
MarkKlein
New Contributor

Thank you for the response!  This has worked out great!

Mark

 

0 Kudos