Conditionally include text in query

Hello

I’ve added loki as datasource for grafana and now I’m creating a dashboard.
I’ve created some variables that correspond to some optional parameters I let the user fill or not, and for each variable filled, I’d like to include a text before the value of the variable set.
ex: I have a variable field company_id on top of the dashboard, hence in the query I’d like to have included company_id= before the value, when and only when the variable is defined.

  • when the variable company_id is not set, the query must look like this
{hostname=~"$hostname", unit=~"$unit"}|="$text_search"
  • when the variable company_id is set, the query must look like this (as if jinja would be allowed {% if company_id is defined %}company_id=$company_id{% endif }%)
{hostname=~"$hostname", unit=~"$unit"}|="$text_search company_id=${company_id}"

grafana version: 8.2.x

Thanks for the help.