How to add interactive filter to panel

I have a query which returns data like:

Location,Station,Last Heartbeat,Timestamp

There are several locations, each of which has a number of stations that I want to monitor. I now show them as a table in Grafana. How can I achieve the following:

  1. add a dropdown box on the panel, which let me select the Location, to show only stations in that location.

  2. further more, if a location is selected, the table shows only stations in that location PLUS all stations whose last heartbeat is over, say, one hour ago, regardless of their locations!

Thanks.