0

I’m working with gauges and I run into a stopper. I hope someone can unblock my issue here. I got a lot of variables which are able to display different data on the same chart. Every other variable is working, but the one I got stuck with is: Año Fiscal ( Fiscal Year) gauge1 gauge2

The query is quite simple and straight forward: gauge3 gauge4

In the following picture, you can see the query working. Also you will be able to see the values of the Variable Año Fiscal: gauge5

In the next iteration of my query I would like to create a clause inside the WHERE in which I could compare if the variable selected is bigger than the values in the column Año Fiscal: Gauge6

When I move that query to Grafana, it returns me an error ( No data ). Gauge7

Do anybody know how to make that comparation with the operator > or < ?. I know that when we place ($Variable), is due to we got a list in the variables. That’s why it comes before the ($Variable) the IN Clause, but maybe we could find a work-around.

I don’t know if we can use other Operators (different from IN ). With the variables.

Thank you very much!

2 Answers2

1

The variable values are interpolated as strings in quotes. From the docs:

The formatting of the variable interpolation depends on the data source, but there are some situations where you might want to change the default formatting.

For example, the default for the MySql data source is to join multiple values as comma-separated with quotes: 'server01','server02'. In some cases, you might want to have a comma-separated string without quotes: server01,server02. You can make that happen with advanced variable formatting options listed below.

So I'm assuming Ano Fiscal is your only numerical variable, where the comparison is not working because it is between numbers and strings.

What you're looking for is the raw variable format.

dnnshssm
  • 1,057
  • 6
  • 17
0

You can check the actual query that grafana sends to your mysql by clicking the "Generated SQL"-button. There you can check if the your dashboard variable is converted into the right format for the mysql query. It is very helpful for debugging.

You should uncheck the option "Multi-value" in the settings of the $anioFiscal. Unless you want to generate a panel for every fiscal year that you select from the list, which would mean that you have to adjust the repeat options of the panel.

Maybe, you need then still neet to manually apply a format option to your variable which fits to the data type in your mysql query, see https://grafana.com/docs/grafana/latest/variables/advanced-variable-format-options/. So for example ${anioFiscal:raw} or ${anioFiscal:singlequote} or ${anioFiscal:text}.

oidamo
  • 141
  • 5