# "filter" functionality for 'when:' conditional

**URL:** <https://forum.ansible.com/t/filter-functionality-for-when-conditional/18373>\
**Category:** Ansible Project\
**Created:** [June 1, 2015, 9:12pm UTC](https://forum.ansible.com/t/filter-functionality-for-when-conditional/18373 "2015-06-01T21:12:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Patrick\_Glomski](https://avatars.discourse-cdn.com/v4/letter/p/b487fb/32.png) [@Patrick\_Glomski](https://forum.ansible.com/u/Patrick_Glomski)\
**Post date:** [June 1, 2015, 9:12pm UTC](https://forum.ansible.com/t/filter-functionality-for-when-conditional/18373/1 "2015-06-01T21:12:37Z")

</div>

When running a task with multiple items using ‘with\_items’, the results are registered in a variable under ‘results’ as a list. Is there any way to apply a filter such as ‘any’ or ‘all’ to that list in a conditional on the next task’s execution? The only way I can do something currently is to perform the following task several times (once for every item in the list that evaluates as true for my condition). I’d rather not notify a handler, because the following tasks depend on this task being evaluated.

simple example I just made up to illustrate what I want:

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [June 1, 2015, 9:46pm UTC](https://forum.ansible.com/t/filter-functionality-for-when-conditional/18373/2 "2015-06-01T21:46:16Z")

</div>

i think this is the droid you are looking for:  
[http://jinja.pocoo.org/docs/dev/templates/#map](http://jinja.pocoo.org/docs/dev/templates/#map)

---

<div class="post-metadata">

**Author:** ![Patrick\_Glomski](https://avatars.discourse-cdn.com/v4/letter/p/b487fb/32.png) [@Patrick\_Glomski](https://forum.ansible.com/u/Patrick_Glomski)\
**Post date:** [June 2, 2015, 11:58am UTC](https://forum.ansible.com/t/filter-functionality-for-when-conditional/18373/3 "2015-06-02T11:58:34Z")

</div>

Thanks so much for your help, Brian! I’ll try to RTFM next time.

Patrick
