# Metric expressions

**URL:** <https://community.dynatrace.com/t/metric-expressions/47018>\
**Category:** Dashboarding\
**Tags:** dynatrace-managed, dashboards\
**Created:** [August 6, 2024, 6:22am UTC](https://community.dynatrace.com/t/metric-expressions/47018 "2024-08-06T06:22:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lucybellonikeyl](https://avatars.discourse-cdn.com/v4/letter/l/67e7ee/32.png) [@Lucybellonikeyl](https://community.dynatrace.com/u/Lucybellonikeyl)\
**Post date:** [August 6, 2024, 6:22am UTC](https://community.dynatrace.com/t/metric-expressions/47018/1 "2024-08-06T06:22:35Z")

</div>

Hello expert,

I’m trying to do a calculation between 2 metrics, but without success.

the following is the expression without a calculation:

core.daemon.user.authentication.count:filter(and(or(eq(step,finish),eq(step,start)))):splitBy(step):sum:sort(value(sum,descending)):limit(20)

I need to calculate step:start- step:finish

Is it possible to dio that?

Thanks,

Luciana

---

<div class="post-metadata">

**Author:** ![dannemca](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/dannemca/32/7215_2.png) [@dannemca](https://community.dynatrace.com/u/dannemca)\
**Post date:** [August 8, 2024, 5:09pm UTC](https://community.dynatrace.com/t/metric-expressions/47018/2 "2024-08-08T17:09:05Z")

</div>

Hi, [@Lucybellonikeyl](https://community.dynatrace.com/user/79086)

try this:

core.daemon.user.authentication.count:filter(and(or(eq(step,start)))):splitBy():sum:sort(value(sum,descending)):limit(20) - core.daemon.user.authentication.count:filter(and(or(eq(step,finish)))):splitBy():sum:sort(value(sum,descending)):limit(20)

---

<div class="post-metadata">

**Author:** ![Cameron-Leong](https://avatars.discourse-cdn.com/v4/letter/c/54ee81/32.png) [@Cameron-Leong](https://community.dynatrace.com/u/Cameron-Leong)\
**Post date:** [August 8, 2024, 6:30pm UTC](https://community.dynatrace.com/t/metric-expressions/47018/3 "2024-08-08T18:30:01Z")

</div>

Hello,

You should be able to do so with a simple subtraction expression. Try something like…

```auto
core.daemon.user.authentication.count:filter(and(or(eq(step,start)))):splitBy(step)
+
core.daemon.user.authentication.count:filter(and(or(eq(step,finish)))):splitBy(step)

```

Here’s a [link](https://docs.dynatrace.com/docs/shortlink/explorer-advanced-query-editor#expressions) to the docs.

---

<div class="post-metadata">

**Author:** ![dannemca](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/dannemca/32/7215_2.png) [@dannemca](https://community.dynatrace.com/u/dannemca)\
**Post date:** [August 8, 2024, 6:47pm UTC](https://community.dynatrace.com/t/metric-expressions/47018/4 "2024-08-08T18:47:42Z")

</div>

The problem here is the splitBy(step). Since the dimensions values are different the calculation will not works. You will need to make it splitBy(), empty, or use other dimension that match on both results.
