# Implementing Custom Functions to use in DQL

**URL:** <https://community.dynatrace.com/t/implementing-custom-functions-to-use-in-dql/51762>\
**Category:** DQL\
**Tags:** dql\
**Created:** [May 22, 2025, 12:05pm UTC](https://community.dynatrace.com/t/implementing-custom-functions-to-use-in-dql/51762 "2025-05-22T12:05:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shapu](https://avatars.discourse-cdn.com/v4/letter/s/ba8739/32.png) [@shapu](https://community.dynatrace.com/u/shapu)\
**Post date:** [May 22, 2025, 12:05pm UTC](https://community.dynatrace.com/t/implementing-custom-functions-to-use-in-dql/51762/1 "2025-05-22T12:05:06Z")

</div>

I am current replicating a function in Splunk to use in my Dynatrace queries.

I have replicated the functionality but through the method below:  
1. Create a code block segment&nbsp;  
2. call the DQL query inside code block using&nbsp;import { queryExecutionClient } from '@dynatrace-sdk/client-query  
3. Get the query results modify it using custom JavaScript function  
4.&nbsp; Get the results of the segment in raw json format  
5. Get the raw JSON result&nbsp; and place it in DQL&nbsp; data json"“” \<json data\>" in DQL, to then chain the subsequent DQL after modifying it\>

Does anyone know a better solution to this approach, which reduces overhead work and have it done in one segment block?

---

<div class="post-metadata">

**Author:** ![StrangerThing](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/strangerthing/32/12182_2.png) [@StrangerThing](https://community.dynatrace.com/u/StrangerThing)\
**Post date:** [May 22, 2025, 2:23pm UTC](https://community.dynatrace.com/t/implementing-custom-functions-to-use-in-dql/51762/2 "2025-05-22T14:23:48Z")

</div>

There are a couple of product ideas already out there and Under Review for creating DQL macros to save and use in later queries:&nbsp;&nbsp;[Introduction of a Macro Feature in Dynatrace DQL - Dynatrace Community](https://community.dynatrace.com/post/256518)
