# Total time for a dimension regarding the timeseries

**URL:** <https://community.dynatrace.com/t/total-time-for-a-dimension-regarding-the-timeseries/51015>\
**Category:** DQL\
**Tags:** dql, dynatrace-managed, timeseries\
**Created:** [April 2, 2025, 9:21am UTC](https://community.dynatrace.com/t/total-time-for-a-dimension-regarding-the-timeseries/51015 "2025-04-02T09:21:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sullivan](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@Sullivan](https://community.dynatrace.com/u/Sullivan)\
**Post date:** [April 2, 2025, 9:21am UTC](https://community.dynatrace.com/t/total-time-for-a-dimension-regarding-the-timeseries/51015/1 "2025-04-02T09:21:07Z")

</div>

Hello everyone,

I want to retrieve the total time of a time series for each service in order to produce a monthly report on the total degradation time per service.

Basic DQL query:

timeseries interval : 1h, health = avg(office365.tenant.service.health, filter : { status == ‘ serviceDegradation ’ }), by : { service }

Do you have any ideas on how to do this please?

Regards,

---

<div class="post-metadata">

**Author:** ![yanezza](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/yanezza/32/5036_2.png) [@yanezza](https://community.dynatrace.com/u/yanezza)\
**Post date:** [April 5, 2025, 6:29pm UTC](https://community.dynatrace.com/t/total-time-for-a-dimension-regarding-the-timeseries/51015/2 "2025-04-05T18:29:32Z")

</div>

Are you meaning like this?

```python
timeseries by:{service}, filter:status == "serviceDegradation", interval:1h, timeframe:timeframe(from:now() - 30d, to:now()), health = avg(office365.tenant.service.health)
| fieldsAdd total_degradation_time = arraySum(health)

```

you can remove the timeframe if you will set it in the notebook section.

---

<div class="post-metadata">

**Author:** ![Sullivan](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@Sullivan](https://community.dynatrace.com/u/Sullivan)\
**Post date:** [April 7, 2025, 8:14am UTC](https://community.dynatrace.com/t/total-time-for-a-dimension-regarding-the-timeseries/51015/3 "2025-04-07T08:14:27Z")

</div>

Hi Yanezza, thanks for your suggestion, I made the DQL query after my post finally, I forgot to close, thanks for your suggestion I created this query :

timeseries by:{service}, filter:status == $Statut, health = avg(office365.tenant.service.health)  
| fieldsAdd health = arrayRemoveNulls(health)  
| fieldsAdd total\_time = toDuration(timeframe)  
| filter isNotNull(total\_time)  
| fieldsAdd arraySize(health)  
| fieldsAdd TempsduStatut=(`arraySize(health)`\*interval)
