How to take the sum of a filtered query

I am trying to take the sum of the query results returned. The challenging part is that the query returns a value per “metric” whose sum returns “no data”

SELECT sum(“sample”) FROM (
last(value) as sample

WHERE “metric” =~ // and $timeFilter
GROUP BY “metric”

@akoumpas what does your unformatted data look like from the returned query?