# Count of Problem in each week by its category of the event type from last one month data

**URL:** <https://community.dynatrace.com/t/count-of-problem-in-each-week-by-its-category-of-the-event-type-from-last-one-month-data/41289>\
**Category:** DQL\
**Tags:** notebooks\
**Created:** [August 22, 2023, 11:16am UTC](https://community.dynatrace.com/t/count-of-problem-in-each-week-by-its-category-of-the-event-type-from-last-one-month-data/41289 "2023-08-22T11:16:24Z")\
**Posts on this page:** 1\
**Showing post:** 10

<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:** [August 23, 2023, 6:53am UTC](https://community.dynatrace.com/t/count-of-problem-in-each-week-by-its-category-of-the-event-type-from-last-one-month-data/41289/10 "2023-08-23T06:53:13Z")

</div>

Hi&nbsp;Bhargav,

My assumption was that in your environment the problems do not last longer than 1 week. You must have problems which have started quite some while ago. So that query does not work pretty well if you have such kind of problems since I am grouping by event start date.

If you group by the timestamp (update time of the event), then the result should look better

```markup
fetch events, from:-30d
| filter event.kind == "DAVIS_PROBLEM" 
| sort timestamp desc
| fieldsAdd weekOf=formatTimestamp(timestamp-duration(getDayOfWeek(timestamp) -1 ,"d"),format:"YYYY-MM-dd")
| summarize {id = takeFirst(display_id), duplicate = takeFirst(dt.davis.is_duplicate), category = takeFirst(event.category)}, by:{display_id,weekOf}
| filter duplicate == false
| summarize `Problem count` = count(), by:{weekOf,category}

```

---

_[View the full topic](https://community.dynatrace.com/t/count-of-problem-in-each-week-by-its-category-of-the-event-type-from-last-one-month-data/41289)._
