# Transform metric to string

**URL:** <https://community.dynatrace.com/t/transform-metric-to-string/39133>\
**Category:** Dashboarding\
**Tags:** dynatrace-managed, dashboards-classic, data-ingest, problems-classic, dynatrace-api\
**Created:** [April 3, 2023, 2:40pm UTC](https://community.dynatrace.com/t/transform-metric-to-string/39133 "2023-04-03T14:40:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rdinis](https://avatars.discourse-cdn.com/v4/letter/r/e8c25b/32.png) [@rdinis](https://community.dynatrace.com/u/rdinis)\
**Post date:** [April 3, 2023, 2:40pm UTC](https://community.dynatrace.com/t/transform-metric-to-string/39133/1 "2023-04-03T14:40:55Z")

</div>

Hi all,

I’m ingesting metrics via api ([Metrics API v2](https://www.dynatrace.com/support/help/shortlink/api-metrics-v2)).

So, I collect a state ( **string=“OK”** ) and in the script I change for a ( **integer = 1** ). The unit type im using is **State**.  
Now in Dynatrace I would like to transform again the metric to string. I have multiple applications with various states so its hard to follow/memorize all the tansformations **String** \<--\> **Integer**.

The challenge that Im facing now is to show the state in a human readable way. I have to create alerts and generate a reasonable dashboard.

1. Is it possible to convert the integer to string inside Dynatrace to generate friendly dashboards?&nbsp;(i have use cases with 10 states 😐)
2. If (1.) its not possible I can use the problem app, but the state of application will be Red/Green.

Thanks all,  
RD

---

<div class="post-metadata">

**Author:** ![Fin\_Ubels](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/fin_ubels/32/18008_2.png) [@Fin\_Ubels](https://community.dynatrace.com/u/Fin_Ubels)\
**Post date:** [April 3, 2023, 11:49pm UTC](https://community.dynatrace.com/t/transform-metric-to-string/39133/2 "2023-04-03T23:49:01Z")

</div>

Hey RD,

In my example below I’m ingesting a metric thats random from 1-99 and has a device name as a dimension. You can then use partitions and a table view to display each dimension (in your case application) as being in a different state based on the last value.

 ![Fin_Ubels_0-1680565624800.png](https://global.discourse-cdn.com/dynatrace/original/3X/5/a/5aa5e790e606c7685518eb8b3be1a4ebd62037f9.png)

The expression I used is as follows:

```markup
test.metric.average:splitBy("devicename"):last:max:partition("State",value("State10",gt(90)),value("State9",gt(80)),value("State8",gt(70)),value("State7",gt(60)),value("State6",gt(50)),value("State5",gt(40)),value("State4",gt(30)),value("State3",gt(20)),value("State2",gt(10)),value("State1",gt(0))):sort(dimension("devicename",descending))

```

Hope this helps!

---

<div class="post-metadata">

**Author:** ![rdinis](https://avatars.discourse-cdn.com/v4/letter/r/e8c25b/32.png) [@rdinis](https://community.dynatrace.com/u/rdinis)\
**Post date:** [April 4, 2023, 9:23am UTC](https://community.dynatrace.com/t/transform-metric-to-string/39133/3 "2023-04-04T09:23:37Z")

</div>

Thank you very much&nbsp;[@Fin\_Ubels](https://community.dynatrace.com/user/47376), exactly what I needed&nbsp;😁
