Filtering entity based on two tags variable in dashboard

With iterative expressions is not necessary to go through expand and summarize sequence as well as converting whole tags array to string for parsing.

I would try this:

fetch `dt.entity.sql:com_dynatrace_extension_sql-oracle_instance`
| fieldsAdd ptags = parse(tags[], """((LD:tag (!<<'\\' ':') LD:value)|LD:tag)""")
| filter in(arrayRemoveNulls(iCollectArray(if(ptags[][tag]=="Department",ptags[][value]))), array($Department))
  and in(arrayRemoveNulls(iCollectArray(if(ptags[][tag]=="Environment",ptags[][value]))), array($Environment))