# DQL nice to know: Using a filter, but when not in filter then show record with empty attribute

**URL:** <https://community.dynatrace.com/t/dql-nice-to-know-using-a-filter-but-when-not-in-filter-then-show-record-with-empty-attribute/49552>\
**Category:** DQL\
**Tags:** dql\
**Created:** [January 2, 2025, 2:52pm UTC](https://community.dynatrace.com/t/dql-nice-to-know-using-a-filter-but-when-not-in-filter-then-show-record-with-empty-attribute/49552 "2025-01-02T14:52:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![henk\_stobbe](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/henk_stobbe/32/30434_2.png) [@henk\_stobbe](https://community.dynatrace.com/u/henk_stobbe)\
**Post date:** [January 2, 2025, 2:52pm UTC](https://community.dynatrace.com/t/dql-nice-to-know-using-a-filter-but-when-not-in-filter-then-show-record-with-empty-attribute/49552/1 "2025-01-02T14:52:16Z")

</div>

Hello,

Maybe this is handy for someone. Suppose you want to use a filter, but you also want to show records not within the filter with an empty attribute

You need to fetch the data twice (-; The “data” example:

data record(rec=1,data =1),  
&nbsp; &nbsp; &nbsp; record(rec=2,data =2) ,  
&nbsp; &nbsp; &nbsp; record(rec=3,data =1),  
&nbsp; &nbsp; &nbsp; record(rec=4,data =3)  
| filter (data == 1)  
| fieldsadd newdata = data  
| append [  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data record(rec=1,data =1),  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;record(rec=2,data =2) ,  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;record(rec=3,data =1),  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;record(rec=4,data =3)]  
| dedup rec, sort:(newdata)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Use the “null” values last!  
| fieldsAdd data = if(isNull(newdata), “”, else:data)&nbsp; //&nbsp; Replace ugly null by “”  
|fieldsRemove newdata&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //&nbsp; &nbsp;Remove the temp column

Result:

 ![henk_stobbe_0-1735829453188.png](https://global.discourse-cdn.com/dynatrace/original/3X/6/a/6ac3c6867900bd4de5313f56619c55aca39c8b69.png)

Any comments, issue’s or has a better way?

KR Henk

---

<div class="post-metadata">

**Author:** ![Tiit\_Hallas](https://avatars.discourse-cdn.com/v4/letter/t/cdc98d/32.png) [@Tiit\_Hallas](https://community.dynatrace.com/u/Tiit_Hallas)\
**Post date:** [January 2, 2025, 3:39pm UTC](https://community.dynatrace.com/t/dql-nice-to-know-using-a-filter-but-when-not-in-filter-then-show-record-with-empty-attribute/49552/2 "2025-01-02T15:39:21Z")

</div>

I might be missing something here, but why not just use the IF clause without the append?

```markup
data 
  record(rec=1,data=1),
  record(rec=2,data=2),
  record(rec=3,data=1),
  record(rec=4,data=3)
| fieldsAdd data = if(data == 1, data, else: "")

```

An example of the result can be seen in the Security Investigator in Dynatrace Playground:&nbsp;[Dynatrace](https://wkf10640.apps.dynatrace.com/ui/apps/dynatrace.security.investigator/share/2e02f2c7-8781-4e95-bd73-d5c792fc9281)

---

<div class="post-metadata">

**Author:** ![henk\_stobbe](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/henk_stobbe/32/30434_2.png) [@henk\_stobbe](https://community.dynatrace.com/u/henk_stobbe)\
**Post date:** [January 2, 2025, 3:55pm UTC](https://community.dynatrace.com/t/dql-nice-to-know-using-a-filter-but-when-not-in-filter-then-show-record-with-empty-attribute/49552/3 "2025-01-02T15:55:37Z")

</div>

Hello,

Thanks for your reply!

You are not missing anything, from where I am sitting you are brilliant!

KR Henk
