Process and plot multiple variables from MYSQL within Grafana

Hello.
I am using MySQL as my data source. I have to plot the change in X with respect to time over my selected time period, where X = (Y^2 + Z^2)^0.5.
If possible, I would like to have Y and Z as variables in my dashboard rather than calculating X directly in a MySQL. From what I understand, I need to create two separate variables for Y and Z associated to my dashboard, and then reference them in my query when plotting in my panel.
I can create variables Y and Z which each contain a series of variables for the time period I have selected, but then I don’t know how to plot them, mainly because I do not understand:

  • where I get the time variable from
  • how Grafana knows what the time variable is to assign to X.

Do I have to extract the time inside the variable queries and call it something specific? OR create a specific time variable and reference that in my plot query?

Here are some example SQL statements which would be entered into my dashboard variable:
SELECT Y as “Y” from my_database;
SELECT Z as “Z” from my_database;

Thank you very much in advance