Does nested templating have events?

I have created nested templates with host being first template and second one being VMs in that host. So when I select the host in first drop down, I get all VMs in that host in second dropdown. But I would like to do a different query say ‘Query B’ when I choose the host on first drop down. Is this option available?
My scenario: I want all hosts before I select the 1st drop down which is HOST, so I’m doing groub by host. When I select the host, I want to see all VMs in that host, for which I have to do groub by VM.

You cannot switch query based on variable value. But you can use variable value in the group by cause to change group by using the variable

Can you explain that or give me an example.

http://play.grafana.org/dashboard/db/influxdb-group-by-variable?panelId=1&fullscreen&edit&orgId=1&var-groupBy=datacenter

this was helpful. Thanks.