# Timeseries dt.availability.state split by hours - business non business

**URL:** <https://community.dynatrace.com/t/timeseries-dt-availability-state-split-by-hours-business-non-business/46644>\
**Category:** DQL\
**Tags:** dql, dynatrace-managed\
**Created:** [July 17, 2024, 6:16am UTC](https://community.dynatrace.com/t/timeseries-dt-availability-state-split-by-hours-business-non-business/46644 "2024-07-17T06:16:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlanFoley](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@AlanFoley](https://community.dynatrace.com/u/AlanFoley)\
**Post date:** [July 17, 2024, 6:16am UTC](https://community.dynatrace.com/t/timeseries-dt-availability-state-split-by-hours-business-non-business/46644/1 "2024-07-17T06:16:05Z")

</div>

Hi All

I am successfully able to calculate an overall monthly Availability % which aligns to the value show in Host Classic for availability for a given host

Here is the DQL:

timeseries {AvailabilityStateUP=sum(dt.host.availability),end()}, filter:availability.state == “up”  
, by: {dt.entity.host,availability.state},interval:1h  
| expand `end()`  
| filter dt.entity.host == “HOST-xxx”  
| fieldsAdd hour = formatTimestamp(`end()`, format:“HH”)  
| sort `end()`

| … rest of DQL statements for Availability Percentage Calculation and output fields

I would like to be able to report on Monthly availability percentage split by Business (06h00-18h00) and Non Business Hours (18h00-06h00) - ideally split at the “timeseries” level

In the screenshot below you can see that “AvailabilityStateUP” contains the array for the WHOLE reporting interval - in this case the last 24 hours - not split by “end()” -&nbsp;&nbsp;&nbsp;I can filter by “hour” after the timeries extraction but it does not help as the array contains all values for the whole reporting period

The problem is the availability figure for each hour will be the availability % calculation of the WHOLE array for the reporting period

I thought I could split by: end() but this is also not possible

I also looked at “bins:” but the documentation did not help me - is this an option? can someone assit with the syntax as per my requirement

 ![AlanFoley_1-1721196206198.png](https://global.discourse-cdn.com/dynatrace/original/3X/e/6/e60bc22f6ecf1b20233282c9128a3649c0653b43.png)

Any other ides? Apprecaite any assistance

Thanks

Alan

---

<div class="post-metadata">

**Author:** ![krzysztof\_hoja](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/krzysztof_hoja/32/34625_2.png) [@krzysztof\_hoja](https://community.dynatrace.com/u/krzysztof_hoja)\
**Post date:** [July 17, 2024, 10:31am UTC](https://community.dynatrace.com/t/timeseries-dt-availability-state-split-by-hours-business-non-business/46644/2 "2024-07-17T10:31:53Z")

</div>

You do not need to expand. You can use iterative expressions:

```c
timeseries {AvailabilityStateUP=sum(dt.host.availability),e=end()}, filter:availability.state == "up" and dt.entity.host == "HOST-000CA78B479207CD"
, by: {dt.entity.host,availability.state},interval:1h
| fieldsAdd AvailabilityStateUP_BH = if( getHour(e[])>=8 and getHour(e[])<=17, AvailabilityStateUP[] )
| fieldsAdd AvailabilityStateUP_NBH = if( getHour(e[])<8 or getHour(e[])>17, AvailabilityStateUP[] )

```

this way you get 2 timeseries, each one filled only values in our outside business hours. Then you can proceed with summarization of the array using array functions.

 ![krzysztof_hoja_1-1721212267538.png](https://global.discourse-cdn.com/dynatrace/original/3X/5/7/5768dfb1303db4083dd16b6795a3db2894307ce0.png)

It is possible with expand too, but you need to construct single array of records containing both: availability metric and time:

```markup
timeseries {AvailabilityStateUP=sum(dt.host.availability),e=end()}, filter:availability.state == "up" and dt.entity.host == "HOST-000CA78B479207CD"
, by: {dt.entity.host,availability.state},interval:1h
| fieldsAdd AvailabilityStateUPWithH = record(av=AvailabilityStateUP[], h=getHour(e[]))
| expand AvailabilityStateUPWithH
| fieldsFlatten AvailabilityStateUPWithH

```

 ![krzysztof_hoja_0-1721212219589.png](https://global.discourse-cdn.com/dynatrace/original/3X/4/1/411372f9b30594b19d814260311484da626b0610.png)

---

<div class="post-metadata">

**Author:** ![AlanFoley](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@AlanFoley](https://community.dynatrace.com/u/AlanFoley)\
**Post date:** [July 17, 2024, 1:07pm UTC](https://community.dynatrace.com/t/timeseries-dt-availability-state-split-by-hours-business-non-business/46644/3 "2024-07-17T13:07:27Z")

</div>

Hi&nbsp;krzysztof\_hoja

The&nbsp;iterative expressions solution is perfect - works like a charm

Really appreciate you taking the time to test and provide a solution

Thanks a mil

Regards

Alan

---

<div class="post-metadata">

**Author:** ![PedroDeodato](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/pedrodeodato/32/32284_2.png) [@PedroDeodato](https://community.dynatrace.com/u/PedroDeodato)\
**Post date:** [October 23, 2025, 4:53pm UTC](https://community.dynatrace.com/t/timeseries-dt-availability-state-split-by-hours-business-non-business/46644/4 "2025-10-23T16:53:43Z")

</div>

Have been struggling with this for a while now!!  
Thank you so much!
