Constant variable replace part of a string

I’m trying to apply a constant variable to a query, but the replacement is not working properly, in a case like this:

FROM $myconstantvar_restOfTheName.report

Grafana doesn’t realize it has to replace it. It just works if I add some character to delimit a start and end, like " ", [[ ]], etc. The documentation says the way to do it would be:

FROM [[$myconstantvar]]_restOfTheName.report

It replaces the value in did, but it doesn’t eliminate those characters, resulting in:

FROM [[myValue]]_restOfTheName.report

When it was supposed to replace for:

FROM myValue_restOfTheName.report

Can someone help me, please?