# Dictionary subset

**URL:** <https://forum.kx.com/t/dictionary-subset/8969>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [July 20, 2014, 6:36pm UTC](https://forum.kx.com/t/dictionary-subset/8969 "2014-07-20T18:36:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![leonbaum2](https://avatars.discourse-cdn.com/v4/letter/l/b3f665/32.png) [@leonbaum2](https://forum.kx.com/u/leonbaum2)\
**Post date:** [July 20, 2014, 6:36pm UTC](https://forum.kx.com/t/dictionary-subset/8969/1 "2014-07-20T18:36:00Z")

</div>

Is there a way to subset a dictionary without having to reconstruct it?In the example below, the last output is what I want:q)d:til[5]!5#.Q.aq)d0| a1| b2| c3| d4| eq)d where 2

---

<div class="post-metadata">

**Author:** ![wp1](https://avatars.discourse-cdn.com/v4/letter/w/db5fbb/32.png) [@wp1](https://forum.kx.com/u/wp1)\
**Post date:** [July 20, 2014, 6:54pm UTC](https://forum.kx.com/t/dictionary-subset/8969/2 "2014-07-20T18:54:00Z")

</div>

(where 2\<key d)#d

---

<div class="post-metadata">

**Author:** ![FutureInSound](https://avatars.discourse-cdn.com/v4/letter/f/73ab20/32.png) [@FutureInSound](https://forum.kx.com/u/FutureInSound)\
**Post date:** [July 21, 2014, 9:43am UTC](https://forum.kx.com/t/dictionary-subset/8969/3 "2014-07-21T09:43:00Z")

</div>

maybe 3\_d&nbsp; is simpler…?

&nbsp;

---

<div class="post-metadata">

**Author:** ![dingzezhu](https://avatars.discourse-cdn.com/v4/letter/d/94ad74/32.png) [@dingzezhu](https://forum.kx.com/u/dingzezhu)\
**Post date:** [July 21, 2014, 4:18pm UTC](https://forum.kx.com/t/dictionary-subset/8969/4 "2014-07-21T16:18:00Z")

</div>

I think it will depend on your searching criteria over the key. the idea would be using cut(\_)

_yourkeytocut \_ yourdict_

(where not key[d]\>2)\_d

? 2014?7?20???UTC+1??6?36?23??Leon Baum???

> Is there a way to subset a dictionary without having to reconstruct it?
> 
> In the example below, the last output is what I want:
> 
> q)d:til[5]!5#.Q.a  
> q)d  
> 0| a  
> 1| b  
> 2| c  
> 3| d  
> 4| e  
> q)d where 2\<key d  
> “de”  
> q){(key[d]x)!value[d]x} where 2\<key d  
> 3| d  
> 4| e
