# Create a 'timeseries-chart' of totals

**URL:** <https://community.dynatrace.com/t/create-a-timeseries-chart-of-totals/51586>\
**Category:** DQL\
**Tags:** dql, logs\
**Created:** [May 12, 2025, 7:03am UTC](https://community.dynatrace.com/t/create-a-timeseries-chart-of-totals/51586 "2025-05-12T07:03:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chiel](https://avatars.discourse-cdn.com/v4/letter/c/41988e/32.png) [@Chiel](https://community.dynatrace.com/u/Chiel)\
**Post date:** [May 12, 2025, 7:03am UTC](https://community.dynatrace.com/t/create-a-timeseries-chart-of-totals/51586/1 "2025-05-12T07:03:52Z")

</div>

Hi All,

I’d like to create a ‘timeseries-chart’ of totals, for example total number of cars per type, per month. Using ‘interval=30d’ gives me a ‘sliding window’ of totals per 30 days, not per month and not starting the first of every month. I want to get an overview of totals for Januari, Februari, Match etc.

Does anyone know how to do this?

Regrads, Chiel

 ![example-totals-per-month.jpg](https://global.discourse-cdn.com/dynatrace/original/3X/1/e/1eba55a010e93120a1506a5679d4aba544be3a13.jpeg)

---

<div class="post-metadata">

**Author:** ![marco\_irmer](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/marco_irmer/32/3038_2.png) [@marco\_irmer](https://community.dynatrace.com/u/marco_irmer)\
**Post date:** [May 12, 2025, 9:41pm UTC](https://community.dynatrace.com/t/create-a-timeseries-chart-of-totals/51586/2 "2025-05-12T21:41:24Z")

</div>

This is possible, but requires some steps. Suppose your starting point is timeseries data with interval=24h. In this case, you would use three additional steps:

1. Transform your timeseries data to generate a separate record for each day. You can start with [this](https://community.dynatrace.com/post/270741) DQL snippet and adapt to your needs.
2. Use the [getMonth](https://docs.dynatrace.com/docs/discover-dynatrace/references/dynatrace-query-language/functions/time-functions#getMonth) function to extract the month of the year into a new field.
3. Use the [summarize](https://docs.dynatrace.com/docs/discover-dynatrace/references/dynatrace-query-language/commands/aggregation-commands#summarize) command to generate totals by month and use this data as the basis for your visualization.

---

<div class="post-metadata">

**Author:** ![Chiel](https://avatars.discourse-cdn.com/v4/letter/c/41988e/32.png) [@Chiel](https://community.dynatrace.com/u/Chiel)\
**Post date:** [May 13, 2025, 6:38am UTC](https://community.dynatrace.com/t/create-a-timeseries-chart-of-totals/51586/3 "2025-05-13T06:38:21Z")

</div>

Hi Marco,

Thanks for your reply.

As you describe it, it worked, but how do you visualize this?

_…_

_| fieldsAdd month = getMonth(timestamp)_  
_| summarize countDistinct(serverName), by:{month,currentOSVersion}_

| month | currentOSVersion | countDistinct(serverName) |
| --- | --- | --- |
| 4 | Microsoft Windows Server 2016 Stand | 141 |
| 4 | Microsoft Windows Server 2019 Standard | 163 |
| 5 | Microsoft Windows Server 2019 Standard | 139 |
| 5 | Microsoft Windows Server 2019 Stand | 164 |
| 5 | Microsoft Windows Server 2022 Standard | 211 |

Because there is no ‘real’ timestamp anymore in the output, it is not possible to make a bar chart or something like that. The **maketimeseries** command would be the most obvious for my initial question, but then you cannot make totals per month.

---

<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:** [May 13, 2025, 8:52pm UTC](https://community.dynatrace.com/t/create-a-timeseries-chart-of-totals/51586/4 "2025-05-13T20:52:09Z")

</div>

_**getMonth()**_ gives you only month number, which will not be nicely cartable on x-axis where we want to see actual time.

let’s start with simpler example where the source is not a metric, but event/logs/etc. If we introduce grouping by timeframes defined as full months using&nbsp;@ time alignment operator then bars will reflect full months:

```markup
fetch bizevents
| summarize count(), by: { event.provider, timeframe = timeframe(from: timestamp@M, to:timestamp@M+1M) }

```

 ![krzysztof_hoja_0-1747168896378.png](https://global.discourse-cdn.com/dynatrace/original/2X/d/dbf382271968a44e21a53a5f166b958e305a6e66.png)

When the source is a metric, steps described by&nbsp;[@marco\_irmer](https://community.dynatrace.com/user/19769)&nbsp;are correct, but I would use technique I described above.

```markup
timeseries { req=sum(dt.service.request.count), timestamp=start() } , by:{http.response.status_code}
| fieldsAdd d=record(timestamp=timestamp[], req=req[])
| expand d
| summarize req=sum(d[req]), by: { http.response.status_code=toString(http.response.status_code), 
  timeframe = timeframe(from: d[timestamp]@M, to:d[timestamp]@M+1M) }

```

 ![krzysztof_hoja_1-1747169435534.png](https://global.discourse-cdn.com/dynatrace/original/2X/f/fe0c3343874143c6353e3d8cc4c168db5dd45fbe.png)

additionally by using _**start()**_ function in _ **timeseries** _, we immediately have timestamp of datapoint

---

<div class="post-metadata">

**Author:** ![Chiel](https://avatars.discourse-cdn.com/v4/letter/c/41988e/32.png) [@Chiel](https://community.dynatrace.com/u/Chiel)\
**Post date:** [May 14, 2025, 7:20am UTC](https://community.dynatrace.com/t/create-a-timeseries-chart-of-totals/51586/5 "2025-05-14T07:20:55Z")

</div>

This is what I was looking for. Thanks a lot!
