# Count of problem based on duration its open. \<1 hour \<12 hours \<24 hours \>24 hours.

**URL:** <https://community.dynatrace.com/t/count-of-problem-based-on-duration-its-open-1-hour-12-hours-24-hours-24-hours/41314>\
**Category:** DQL\
**Tags:** dql, notebooks\
**Created:** [August 23, 2023, 5:46am UTC](https://community.dynatrace.com/t/count-of-problem-based-on-duration-its-open-1-hour-12-hours-24-hours-24-hours/41314 "2023-08-23T05:46:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bhargav\_314](https://avatars.discourse-cdn.com/v4/letter/b/e19adc/32.png) [@Bhargav\_314](https://community.dynatrace.com/u/Bhargav_314)\
**Post date:** [August 23, 2023, 5:46am UTC](https://community.dynatrace.com/t/count-of-problem-based-on-duration-its-open-1-hour-12-hours-24-hours-24-hours/41314/1 "2023-08-23T05:46:13Z")

</div>

Hi Team,

Can you please let me know how to apply these filters and get the counts based on duration of the problem open.

Requirement:&nbsp;Count of problem based on duration its open. \<1 hour \<12 hours \<24 hours \>24 hours.

fetch events, from:-30d  
| filter event.kind == “DAVIS\_PROBLEM”

| fieldsAdd open\_ts = if(event.status == “ACTIVE” AND event.status\_transition == “UPDATED”,timestamp)  
| filter isNotNull(open\_ts)  
| summarize  
open = min(open\_ts),  
by:{display\_id, event.category, event.name }  
| summarize  
count=countDistinct(display\_id),  
by:{open}

| summarize count = count()  
| sort count desc

---

<div class="post-metadata">

**Author:** ![ChadTurner](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/chadturner/32/161_2.png) [@ChadTurner](https://community.dynatrace.com/u/ChadTurner)\
**Post date:** [February 12, 2024, 7:54pm UTC](https://community.dynatrace.com/t/count-of-problem-based-on-duration-its-open-1-hour-12-hours-24-hours-24-hours/41314/2 "2024-02-12T19:54:57Z")

</div>

[@Bhargav\_314](https://community.dynatrace.com/user/63764)&nbsp;were you able to get a DQL statement that achieves your desired outcome?

---

<div class="post-metadata">

**Author:** ![sinisa\_zubic](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/sinisa_zubic/32/32498_2.png) [@sinisa\_zubic](https://community.dynatrace.com/u/sinisa_zubic)\
**Post date:** [February 12, 2024, 8:22pm UTC](https://community.dynatrace.com/t/count-of-problem-based-on-duration-its-open-1-hour-12-hours-24-hours-24-hours/41314/3 "2024-02-12T20:22:24Z")

</div>

Hi all

That should be the query you are looking for

```markup
fetch events, from:now()-370m
| filter dt.system.bucket == "default_davis_events"
| filter event.kind == "DAVIS_PROBLEM"
| summarize {problem=takeMax(record(timestamp,resolved_problem_duration,dt.davis.is_duplicate,event.status,maintenance.is_under_maintenance,dt.davis.is_frequent_event, event.start)) }, by:{display_id}
| fieldsFlatten problem
| filter problem.event.status != "CLOSED"
| filter problem.dt.davis.is_duplicate == false and problem.maintenance.is_under_maintenance == false
| fieldsAdd duration_bucket = if(problem.event.start < now() - 24h, "> 24h")
| fieldsAdd duration_bucket = if(problem.event.start >= now() - 24h, "< 24h", else: duration_bucket)
| fieldsAdd duration_bucket = if(problem.event.start >= now() - 12h, "< 12h", else: duration_bucket)
| fieldsAdd duration_bucket = if(problem.event.start > now() - 1h, "< 1h", else: duration_bucket)
| summarize count = count(), by: { duration_bucket }

```

Best,  
Sini
