Ok so I feel I'm close on this. I used the code you gave me, modifed it to return the total flush lengths of pipe divided by the number of ROWIDs to get the daily average length of pipes flushed.
The issue I am getting is that the count for ROW__ID is way off, currently there are 21 in the output, but only 7 show up in the count. Also when I click done, the indicator is unable to execute script, even though the test results return a value. Any thoughts and also, really do appreciate the help you already gave!
var tvwdportal = Portal('https://mapping.tvwd.org/portal')
var flush2023 = "LifeCycleStatus = 'ACTIVE' And OwnedBy = 'TVWD' And Diameter <= 12 And LastFlushDate >= date '2023-10-26'"
var main2023 = Filter(FeatureSetByPortalItem(tvwdportal,"b24772e427084f21b1f208a685d07fcc",48,['LastFlushDate','Shape__Length'],True), flush2023) ;
var flushlength = LengthGeodetic(main2023, 'm');
GroupBy(
main2023,
[
{name: 'theYear', expression: 'EXTRACT(YEAR FROM LastFlushDate)'},
{name: 'theMonth', expression: 'EXTRACT(MONTH FROM LastFlushDate)'},
{name: 'theDate', expression: 'EXTRACT(DAY FROM LastFlushDate)'},
],
[
{name: 'flushcount', expression: '1', statistic: 'COUNT'},
{name: 'length', expression: 'Shape__Length', statistic: 'SUM'}
]
)
return sum(flushlength/count('ROW_ID'))