Splunk's version of arrays is multivalue field, so if you change you input to a multivalue field, you could do something like this | eval Tag = split(lower("Tag3,Tag4"),",")
| spath
| foreach *Tags{}
[| eval field="<<FIELD>>"
| foreach <<FIELD>> mode=multivalue
[| eval tags=if(isnull(tags),if(mvfind(Tag,lower('<<ITEM>>')) >= 0, field, null()),mvappend(tags, if(mvfind(Tag,lower('<<ITEM>>')) >= 0, field, null())))]
]
| stats values(tags)
... View more