Sum the Results of a Filtered Macro Call

Hello! Everyone was so helpful when I needed to add a video background to my Tiddlywiki, so I thought I’d come looking for help with my newest roadblock.

I want to sum the results of a macro that calculates the total distance of a navigation route that is stored as line data in the text field of a filtered series of GeoJSON tiddlers (I’m mapping the data with Leaflet). The macro works great for a single GeoJSON data tiddler, but I can’t figure out how to run the macro on a filtered set of GeoJSON data tiddlers and return a sum of the distance from each data tiddler.

The macro call for a single data tiddler is (where KnoxvilleSideTripData is my GeoJSON tiddler):

Knoxville Side Trip | Distance: <$macrocall $name=“calctotaldistance” geodata={{KnoxvilleSideTripData!!text}} /> Miles

I’m using checkboxes to “select” different segments to add to the total mileage (and to the map), so the filtered Leaflet call for all of the selected routes is (this works just fine):

<$leafmap tile=‘osm’ places=’{“filter”:"[!has[draft.of]tag[Selected]]"}’/>

What I’d like to do is to use the [!has[draft.of]tag[Selected]] filter to return the distance of each selected route segment and total the results. I know that macro calls just subs params and vars and then transcludes the macro contents into the macro call, and that to get the value it’s necessary to wikify the macro results, but I don’t know how to properly combine the 3 operations (filtered macro calls, wikify results, sum results).

Update: I put the working version of my TW here: https://lifelivedsideways.net/

Any help out there? Thanks in advance!