# Use the negation operator in DPL

**URL:** <https://community.dynatrace.com/t/use-the-negation-operator-in-dpl/40022>\
**Category:** DQL\
**Tags:** dql\
**Created:** [June 1, 2023, 7:00am UTC](https://community.dynatrace.com/t/use-the-negation-operator-in-dpl/40022 "2023-06-01T07:00:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![educampver](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/educampver/32/29917_2.png) [@educampver](https://community.dynatrace.com/u/educampver)\
**Post date:** [June 1, 2023, 7:00am UTC](https://community.dynatrace.com/t/use-the-negation-operator-in-dpl/40022/1 "2023-06-01T07:00:53Z")

</div>

Hi,

How can we use the negation operator in DPL? For instance, in the example below, the DataKey is always a string of 24 digits. It is essentially a timestamp followed by an identifier. I need to check log records when this DataKey is malformed or has a length of less than 24 characters.&nbsp;Example log record:

```auto
<span><TaskQueue ... DataKey="202303281310073066696996"><br> ...<br></TaskQueue></span>

```

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![sinisa\_zubic](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/sinisa_zubic/32/32498_2.png) [@sinisa\_zubic](https://community.dynatrace.com/u/sinisa_zubic)\
**Post date:** [June 1, 2023, 10:59am UTC](https://community.dynatrace.com/t/use-the-negation-operator-in-dpl/40022/2 "2023-06-01T10:59:09Z")

</div>

Hi there,

please have a look at following query

```markup
data record(content="""<TaskQueue DataKey="202303281310073066696997"></TaskQueue>""")
| parse content, "DATA 'DataKey=' DQS:datakey"
| parse datakey, "TIMESTAMP('YYYYMMddHHmmssSSSSS'):date"
| parse datakey, "[0-9]{24}:numandlength"
| fieldsAdd malformed = if(isNull(datakey),true,else:false)
| fieldsAdd malformed = if(isNull(date),true,else:malformed)
| fieldsAdd malformed = if(isNull(numandlength),true,else:malformed )
| fieldsAdd malformed = if(Stringlength(datakey)!=24,true,else:malformed)

```

some explanation

- fist lets parse and extract the DataKey from the content. It is within a double-quoted string (therefore the DQS matcher)
- then let’s parse the and extract DataKey to date and as well to a 24 digits long number
- afterward you check if any of those fields isNull. If yes, you set malformed to true

Best,  
Sini
