Count number values in a template variable

Hi,
I have a tag_name (node) with node ips (192.168.1.1, 192.168.1.2 etc) and i want to count the number of the exist nodes.
Is there a way to count the number of values in a template variable?

Your exact use case is not clear. I assume that InfluxDB is used, so you can use InfluxDB directly - https://docs.influxdata.com/influxdb/v1.7/query_language/spec/#show-tag-values-cardinality