# How to calculate a ratio between two metrics in Dynatrace SaaS Dashboards (DQL)?

**URL:** <https://community.dynatrace.com/t/how-to-calculate-a-ratio-between-two-metrics-in-dynatrace-saas-dashboards-dql/52458>\
**Category:** Dashboarding\
**Tags:** dynatrace-managed, dashboards\
**Created:** [July 12, 2025, 6:33am UTC](https://community.dynatrace.com/t/how-to-calculate-a-ratio-between-two-metrics-in-dynatrace-saas-dashboards-dql/52458 "2025-07-12T06:33:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Irdina](https://avatars.discourse-cdn.com/v4/letter/i/5fc32e/32.png) [@Irdina](https://community.dynatrace.com/u/Irdina)\
**Post date:** [July 12, 2025, 6:33am UTC](https://community.dynatrace.com/t/how-to-calculate-a-ratio-between-two-metrics-in-dynatrace-saas-dashboards-dql/52458/1 "2025-07-12T06:33:54Z")

</div>

Hi,  
I’m new to Dynatrace and DQL, and I’d appreciate some advice. I’d like to calculate a ratio between two metrics (avg(read\_time) / avg(write\_time)) and display it as a single value in the Dynatrace SaaS Dashboards App.

Is this possible, and what’s the correct way to do it?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Emm4nuel](https://avatars.discourse-cdn.com/v4/letter/e/e9bcb4/32.png) [@Emm4nuel](https://community.dynatrace.com/u/Emm4nuel)\
**Post date:** [July 12, 2025, 7:59pm UTC](https://community.dynatrace.com/t/how-to-calculate-a-ratio-between-two-metrics-in-dynatrace-saas-dashboards-dql/52458/2 "2025-07-12T19:59:00Z")

</div>

Hi Irdina,

Please try this DQL and see if this is what you are trying to achieve:

This is a time series showing the&nbsp; **ratio of average disk write time to average disk read time** &nbsp;over time, with the intermediate metrics removed for clarity.

```javascript
timeseries { write_time = avg(dt.host.disk.write_time), read_time = avg(dt.host.disk.read_time) }
| fieldsAdd expression = write_time[] / read_time[]
| fieldsRemove write_time, read_time

```

---

<div class="post-metadata">

**Author:** ![Irdina](https://avatars.discourse-cdn.com/v4/letter/i/5fc32e/32.png) [@Irdina](https://community.dynatrace.com/u/Irdina)\
**Post date:** [July 14, 2025, 3:45am UTC](https://community.dynatrace.com/t/how-to-calculate-a-ratio-between-two-metrics-in-dynatrace-saas-dashboards-dql/52458/3 "2025-07-14T03:45:39Z")

</div>

Yes, thank you for the help, the solution u gave is a great start to have.

---

<div class="post-metadata">

**Author:** ![Irdina](https://avatars.discourse-cdn.com/v4/letter/i/5fc32e/32.png) [@Irdina](https://community.dynatrace.com/u/Irdina)\
**Post date:** [July 14, 2025, 3:47am UTC](https://community.dynatrace.com/t/how-to-calculate-a-ratio-between-two-metrics-in-dynatrace-saas-dashboards-dql/52458/4 "2025-07-14T03:47:17Z")

</div>

Current update:  
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
timeseries {  
write\_time = avg(dt.host.disk.write\_time),  
read\_time = avg(dt.host.disk.read\_time)  
}  
| fieldsAdd wt = arrayAvg(write\_time), rt = arrayAvg(read\_time)  
| fieldsAdd ratio = concat(tostring(toLong(wt)), “:”, tostring(toLong(rt)))  
| fieldsKeep ratio  
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
I extended the logic to convert the metric outputs into scalar values suitable for a single value tile. I also included a string-based ratio format
