# Add these values

**URL:** <https://community.dynatrace.com/t/add-these-values/43518>\
**Category:** DQL\
**Tags:** dql\
**Created:** [January 9, 2024, 2:14pm UTC](https://community.dynatrace.com/t/add-these-values/43518 "2024-01-09T14:14:22Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![yuval1983](https://avatars.discourse-cdn.com/v4/letter/y/0ea827/32.png) [@yuval1983](https://community.dynatrace.com/u/yuval1983)\
**Post date:** [January 11, 2024, 10:57am UTC](https://community.dynatrace.com/t/add-these-values/43518/12 "2024-01-11T10:57:12Z")

</div>

OK

Could you assist me in inserting a value into this code? I am having trouble inserting it in a way that it will filter rather than tag. Below is the code that I have mentioned earlier

import { metricsClient } from ‘@dynatrace-sdk/client-classic-environment-v2’;

export default async function fetchMetricResults() {  
const serviceSelection = $Service;  
const metricKey = “builtin:service.errors.total.rate”;

const config = {  
metricSelector: buildQuery(serviceSelection, metricKey),  
resolution: “Inf”,  
from: $dt\_timeframe\_from,  
to: $dt\_timeframe\_to,  
acceptType: “application/json; charset=utf-8”  
};

if (config.metricSelector.length \> 3500) {  
return “Please select fewer services”;  
}

const metricQuery = await metricsClient.query(config);

const processedResults: MetricResult[] = metricQuery.result[0].data.map(result =\> {  
return {  
“Service Name”: result.dimensionMap[“dt.entity.service.name”],  
“Service ID”: result.dimensionMap[“dt.entity.service”],  
“Tag”:&nbsp; xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,&nbsp;&nbsp;  
“Failure Rate”: +result.values  
};  
});

return processedResults;  
}

function buildQuery(inputs: string[], metricKey: string): string {  
const filters = inputs.map(  
input =\> `in(“dt.entity.service”, entitySelector(“type(service), entityName.equals(~”${input}~“)”))`  
);  
const filterString = filters.join(“,”);

return `${metricKey}:filter(or(${filterString})):splitBy(“dt.entity.service”):sort(value(auto, descending)):names`;  
}

---

_[View the full topic](https://community.dynatrace.com/t/add-these-values/43518)._
