# Is it possible to get list of models by tag selector inside macro

**URL:** <https://discourse.getdbt.com/t/is-it-possible-to-get-list-of-models-by-tag-selector-inside-macro/11289>\
**Category:** Help\
**Tags:** node-selection, macros\
**Created:** [December 21, 2023, 8:10pm UTC](https://discourse.getdbt.com/t/is-it-possible-to-get-list-of-models-by-tag-selector-inside-macro/11289 "2023-12-21T20:10:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sphinks](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/sphinks/32/3433_2.png) [@sphinks](https://discourse.getdbt.com/u/sphinks)\
**Post date:** [December 21, 2023, 8:10pm UTC](https://discourse.getdbt.com/t/is-it-possible-to-get-list-of-models-by-tag-selector-inside-macro/11289/1 "2023-12-21T20:10:31Z")

</div>

I’m doing some specific actions with models tagged. Names of those models have to hardcode inside macros, but as number is increasing - it is easy to forget them. All those models could be easily picked up by tag.

Is there a way to use selector by tag inside macro to get list of model having such tag?

---

<div class="post-metadata">

**Author:** ![alyk](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/alyk/32/3347_2.png) [@alyk](https://discourse.getdbt.com/u/alyk)\
**Post date:** [December 26, 2023, 5:49pm UTC](https://discourse.getdbt.com/t/is-it-possible-to-get-list-of-models-by-tag-selector-inside-macro/11289/2 "2023-12-26T17:49:22Z")

</div>

according to [this reply](https://discourse.getdbt.com/t/dbt-cloud-commands-in-script/5964/2) can’t run dbt CLI commands from a macro.  
But, tags look to be part of the [graph context variable](https://docs.getdbt.com/reference/dbt-jinja-functions/graph), which is accessible from a macro

---

<div class="post-metadata">

**Author:** ![sphinks](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/sphinks/32/3433_2.png) [@sphinks](https://discourse.getdbt.com/u/sphinks)\
**Post date:** [January 2, 2024, 4:55pm UTC](https://discourse.getdbt.com/t/is-it-possible-to-get-list-of-models-by-tag-selector-inside-macro/11289/3 "2024-01-02T16:55:41Z")

</div>

Thank you! That is what I was looking for!
