Simply add aggregate( @layer, 'sum', [your expression] )
and replace [your expression]
with the expression you provided.
So the whole expression will look like, where apart from the first three and the last line, it is the expression you first provided (be sure the syntax is correct, include all single quotes '
):
aggregate(
@layer,
'sum',
length (
transform (
make_line (
geometry (
get_feature_by_id (
@layer,
$id
)
),
geometry (
get_feature_by_id (
@layer,
$id+1
)
)
),
'EPSG:4326',
'EPSG:23033'
)
)
)