# How to add metrics, some of which may be null?

**URL:** <https://community.dynatrace.com/t/how-to-add-metrics-some-of-which-may-be-null/33705>\
**Category:** Open Q&A\
**Tags:** dynatrace-managed\
**Created:** [January 6, 2022, 4:38pm UTC](https://community.dynatrace.com/t/how-to-add-metrics-some-of-which-may-be-null/33705 "2022-01-06T16:38:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bryceamacker](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bryceamacker](https://community.dynatrace.com/u/bryceamacker)\
**Post date:** [January 6, 2022, 4:38pm UTC](https://community.dynatrace.com/t/how-to-add-metrics-some-of-which-may-be-null/33705/1 "2022-01-06T16:38:46Z")

</div>

Hello, I am trying to build some queries that will add multiple metrics together for single value visualizations. The issue is some of these metrics could potentially be empty but are expected to eventually have data. I’m having trouble finding a way to ignore or set defaults to those empty metrics from the total addition aggregation, which breaks the entire query.

As an example, assume you are consuming DDU metrics, but not DDU logs (at the moment, but plan to). If I wanted to have a visualization of total DDU consumption, I’d try:

```markup
(builtin:billing.ddu.log.total)+(builtin:billing.ddu.metrics.total):auto:sort(value(sum,descending))

```

And due to ddu.log.total (at the moment) being empty, the entire query with the error out with:

“Result of metric expression was empty because one of the inputs was empty. `(builtin:billing.ddu.log.total)` was empty but `(builtin:billing.ddu.metrics.total):auto:sort(value(sum,descending))` had 1 dimension tuples.”

I have tried using the&nbsp; **default** transformation, but I get this error when adding it to any part of the query:“Illegal transform operator: Usage of default operator is only supported for resolutions other than `Inf`.”

---

<div class="post-metadata">

**Author:** ![AgniLanka](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AgniLanka](https://community.dynatrace.com/u/AgniLanka)\
**Post date:** [January 6, 2022, 4:41pm UTC](https://community.dynatrace.com/t/how-to-add-metrics-some-of-which-may-be-null/33705/2 "2022-01-06T16:41:59Z")

</div>

try&nbsp;(builtin:billing.ddu.metrics.total):default( **0** )

---

<div class="post-metadata">

**Author:** ![bryceamacker](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bryceamacker](https://community.dynatrace.com/u/bryceamacker)\
**Post date:** [January 6, 2022, 4:45pm UTC](https://community.dynatrace.com/t/how-to-add-metrics-some-of-which-may-be-null/33705/3 "2022-01-06T16:45:26Z")

</div>

Unfortunately I get the error:

“Illegal transform operator: Usage of default operator is only supported for resolutions other than `Inf`.”

 ![bryceamacker_0-1641487488728.png](https://global.discourse-cdn.com/dynatrace/original/3X/f/b/fb6e428374dc2aad5829fc3f0b9cc484c6e1e855.png)

---

<div class="post-metadata">

**Author:** ![uros\_djukic1](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/uros_djukic1/32/37084_2.png) [@uros\_djukic1](https://community.dynatrace.com/u/uros_djukic1)\
**Post date:** [January 19, 2022, 9:32am UTC](https://community.dynatrace.com/t/how-to-add-metrics-some-of-which-may-be-null/33705/4 "2022-01-19T09:32:10Z")

</div>

Hi&nbsp;[@bryceamacker](https://community.dynatrace.com/user/45824)&nbsp;,  
Please try rather this way :&nbsp;  
(builtin:billing.ddu.metrics.total:splitBy():sum:auto:sort(value(sum,descending)))+(builtin:billing.ddu.log.total:splitBy():sum:auto:sort(value(sum,descending)))

given that splitby() allow to rid of dimensions and return accurate value from targeted metric.  
Thanks

---

<div class="post-metadata">

**Author:** ![ruofei\_wang](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@ruofei\_wang](https://community.dynatrace.com/u/ruofei_wang)\
**Post date:** [March 10, 2022, 3:51pm UTC](https://community.dynatrace.com/t/how-to-add-metrics-some-of-which-may-be-null/33705/5 "2022-03-10T15:51:40Z")

</div>

Hi, I am trying to us splitby(), but still get the empty warning which does not allow me to proceed this calculation

calc:apps.web.\_AAAA:splitBy():count:auto:sort(value(avg,descending)) - (calc:apps.web.\_BBBB:splitBy():count:auto:sort(value(avg,descending)))&nbsp; &nbsp;metric BBBB is the one which has “no data” at some point of time, but I want to leave it as 0 if there is no data
