# SLO using a calculated service metric with no data result in an error - any workaround?

**URL:** <https://community.dynatrace.com/t/slo-using-a-calculated-service-metric-with-no-data-result-in-an-error-any-workaround/47141>\
**Category:** Automations\
**Tags:** dynatrace-managed, slo\
**Created:** [August 13, 2024, 2:45pm UTC](https://community.dynatrace.com/t/slo-using-a-calculated-service-metric-with-no-data-result-in-an-error-any-workaround/47141 "2024-08-13T14:45:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rsmsdk](https://avatars.discourse-cdn.com/v4/letter/r/e19adc/32.png) [@rsmsdk](https://community.dynatrace.com/u/rsmsdk)\
**Post date:** [August 13, 2024, 2:45pm UTC](https://community.dynatrace.com/t/slo-using-a-calculated-service-metric-with-no-data-result-in-an-error-any-workaround/47141/1 "2024-08-13T14:45:24Z")

</div>

Hi

I have a calculated service metric that track a key request count with a processing time of \>10 seconds.

I want to use this metric in a SLO to track how many of the total key request are within a timeout limit set in an application.

The problem occur when no requests have a processing time of \> 10 seconds, and the metrics return “no data” which in return causes my SLO to fail instead of showcasing 100%.

Obviously the metric expression can not use null or zero in the definition, so I was wondering if there is another way to get the result om looking for?

**Metric expression:**  
((calc:service.total-request.count":splitBy()-calc:service.custom-metric-bad-request-count":splitBy())/calc:service.total-request-count":splitBy())\*100

When&nbsp;calc:service.custom-metric-bad-request-count have data, the metric express produces the SLO output I’m looking for, but when&nbsp;calc:service.custom-metric-bad-request-count dont have any data the SLO fail.

**Thank you in advance.**

---

<div class="post-metadata">

**Author:** ![mizso74](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/mizso74/32/41729_2.png) [@mizso74](https://community.dynatrace.com/u/mizso74)\
**Post date:** [August 13, 2024, 3:39pm UTC](https://community.dynatrace.com/t/slo-using-a-calculated-service-metric-with-no-data-result-in-an-error-any-workaround/47141/2 "2024-08-13T15:39:01Z")

</div>

Hi&nbsp;[@rsmsdk](https://community.dynatrace.com/user/42071),

Have you tired the default transformation? (your expression above):default(100)

[Metrics API - Metric expressions - Dynatrace Docs](https://docs.dynatrace.com/docs/dynatrace-api/environment-api/metric-v2/metric-expressions#cover-data-gaps-with-the-default-transformation)

[Metric selector conversion guide - Dynatrace Docs](https://docs.dynatrace.com/docs/observe-and-explore/metrics/upgrade/metric-selector-conversion)

I hope it helps.

Best regards,

Mizső

---

<div class="post-metadata">

**Author:** ![rsmsdk](https://avatars.discourse-cdn.com/v4/letter/r/e19adc/32.png) [@rsmsdk](https://community.dynatrace.com/u/rsmsdk)\
**Post date:** [August 14, 2024, 7:48am UTC](https://community.dynatrace.com/t/slo-using-a-calculated-service-metric-with-no-data-result-in-an-error-any-workaround/47141/3 "2024-08-14T07:48:40Z")

</div>

Thank you so much for taking the time to provide an answer.

I tried adding :defualt(0) to my calculated metric that lack data, but it does not work. I can then add :defualt(0,always) like suggested in [this thread](https://community.dynatrace.com/post/208824) on the same topic, but the math does not add up.

I can isolate the individual metrics, and get a confirmation on the data, but when I set up the expression for calculation, the result does not match.

I can setup&nbsp;calc:service.custom-metric-bad-request-count":splitBy():default(0, always) by itself and display zero, but when I try to setup the expression the output is wrong.

An example with values could be ((200-0)/(200))\*100

Red = Calculated metric with no data and the addition of&nbsp;:default(0, always)  
Green = Total count

Obivously this should output 100, but it does not. It output a number that is nowhere close.

---

<div class="post-metadata">

**Author:** ![fpereira22](https://avatars.discourse-cdn.com/v4/letter/f/258eb7/32.png) [@fpereira22](https://community.dynatrace.com/u/fpereira22)\
**Post date:** [August 19, 2024, 6:49pm UTC](https://community.dynatrace.com/t/slo-using-a-calculated-service-metric-with-no-data-result-in-an-error-any-workaround/47141/4 "2024-08-19T18:49:56Z")

</div>

I have the same problem, I need to bring a calculated metric of no response (another item that is not included) and when I try to remove the SLO, it breaks the entire expression.

Send some examples of my problem:

 ![fpereira22_0-1724093585910.png](https://global.discourse-cdn.com/dynatrace/original/3X/2/e/2ee8d28bc74abc3f04431e95116866a2c85a6cd6.png)

 ![fpereira22_1-1724093628045.png](https://global.discourse-cdn.com/dynatrace/original/3X/2/6/2687e9312a4c91dc79bb3da5a175b07f28763e24.png)

 ![fpereira22_3-1724093750691.png](https://global.discourse-cdn.com/dynatrace/original/3X/f/8/f870fd2f0f5569b48a3f059f04e9561df78676d0.png)

 ![fpereira22_2-1724093653923.png](https://global.discourse-cdn.com/dynatrace/original/3X/6/8/68e910626f2d202e6caaf76e6beef7d446b103ba.png)

calc:service.statuscode\_noresponse\_loyalty:splitby() = 4 counts

calc:service.statuscode\_noresponse\_loyalty:splitby():default(0,always) = 4 counts

(1)+(calc:service.statuscode\_noresponse\_loyalty:splitby()) = 5 counts  
(1)+(calc:service.statuscode\_noresponse\_loyalty:splitby():default(0,always)) = 124 counts???

Does anyone have any suggestions?

---

<div class="post-metadata">

**Author:** ![paulo\_calaxa](https://avatars.discourse-cdn.com/v4/letter/p/9e8a1a/32.png) [@paulo\_calaxa](https://community.dynatrace.com/u/paulo_calaxa)\
**Post date:** [August 20, 2024, 9:51am UTC](https://community.dynatrace.com/t/slo-using-a-calculated-service-metric-with-no-data-result-in-an-error-any-workaround/47141/5 "2024-08-20T09:51:52Z")

</div>

[@rsmsdk](https://community.dynatrace.com/user/42071)&nbsp;[@fpereira22](https://community.dynatrace.com/user/73123)&nbsp;  
Because of having a calculated, or just because of having different metrics, it must be applying a different aggregation from the intended…  
Apply a Fold transformation. For instance:

(  
(builtin:service.requestCount.total:value:splitBy() - calc:service…:value:splitBy():default(0,always)):fold(value) / builtin:service.requestCount.total:value:splitBy():fold(value)  
)  
\* 100
