I have a table that I need to find a total duration of attributes.
How do I calculate the Duration and put the total in a new field?
Dave - I know this tool may not be what you're looking for, but Summary Statistics (Analysis), would provide a sum of the Duration values BUT it creates a new output table in your geodatabase vs. in the existing feature class table. You could use a Join of the output table to the feature class table though if that would suffice.
That looks like the path to go down but I keep getting this error when I try to use Sum for statistic type.
ERROR 000315 Field Duration only supports statistic types MIN, MAX, MEAN, COUNT, FIRST, LAST, UNIQUE.
Is duration a string? You'd be best creating a new 'seconds' field and doing a field calculate using python.
Not tested it at all but something along the lines of : (I know it would be less verbose as a code block)
(float(duration.split(":")[0]) * 3600) + (float(duration.split(":")[1]) * 60) +(float(duration.split(":")[2]))
Something along the lines of this? Duration is the new field and SUM_Total_Seconds is the seconds field
Sum_Total_Seconds = [f.type for f in arcpy.ListFields(SUM_Total_Seconds) if f.name == sDep][0] arcpy.management.CalculateField("mStatistics", "Duration", "!Duration!", "PYTHON3", '(float(SUM_Total_Seconds.split(":")[0]) * 3600) + (float(SUM_Total_Seconds.split(":")[1]) * 60) +(float(SUM_Total_Seconds.split(":")[2]))', "TEXT", "NO_ENFORCE_DOMAINS")
I keep getting an error when I try this:
ERROR 002717: Invalid Arcade expression, Arcade error: Close parenthesis expected, Script line: 1
But I don't see where you'd close the parenthesis?
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.