1

Is there any way to use a textbox panel variable in a where clause for a state panel query?

My Dashboard has a panel variable (type Textbox) variable for current month ($CURRENT_MONTH) with a value of Feb 2021 That variable is used to update the title of a panel using $CURRENT_MONTH

I need to use that variable in the panel's query to complete the where clause logic

SELECT
  availability
FROM "mytable"
where
  dashboard='OPS Dashboard' and period=$CURRENT_MONTH

and throws the error pq: syntax error at or near "2021"

(If I replace $CURRENT_MONTH with 'Feb 2021' it works just fine)

it won't work and throws the error:

1 Answer 1

1

You need to pay attention to quotes:

SELECT availability 
FROM "mytable" 
WHERE dashboard='OPS Dashboard' 
  AND period='$CURRENT_MONTH'

Your homework: use Grafana query inspector and check generated SQL with and without quotes - then you should to understand a reason of quotes here.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.