Getting trace duration in Span table view

In Grafana I am using TraceQL to find traces that match specific conditions.
For those traces I want to do some trasnformations at the span level, and then aggregate again the data to show something aggregated per trace.

For instance, I want to find all the traces that have at least one span with span.attribute_1="test".
Then, if any of the spans has the status as error I want to “mark the trace as failed”.

I managed to do that, but I also want to show the trace duration. The problem is that the trace:duration or traceDuration property is not available as a field in my transformations no matter what I tried.

I would really appreciate some guidance here.

This is an example of my query:
{ resource.k8s.cluster.name = "$cluster_name"} && {span.cloudevents.event_source = "xyz" } | select(span:status)

I also tried including the trace duration intrinstic like:
{ resource.k8s.cluster.name = "$cluster_name"} && {span.cloudevents.event_source = "xyz" } | select(span:status, trace:duration)

or

{ resource.k8s.cluster.name = "$cluster_name"} && {span.cloudevents.event_source = "xyz" } | select(span:status, traceDuration)

or even

{ resource.k8s.cluster.name = "$cluster_name"} && {span.cloudevents.event_source = "xyz" && trace:duration > 0 } | select(span:status)