I rebuild your example with an application of my own. Had no problems with QV, it works as expected. I suspect the syntax (or value) of your variable. So please send your expression and your variable or even better a little app with the whole chart.
I did the same as you in a dummy document and it worked. So I decided to create a new document from scratch, copy the script and copy all the objects. It worked like this. Both documents are exactly the same (script and objects)
It was a document that was created originally in 8.2 even if now we have 9 SR6. It is not the first time that I have unexpected problems with old documents that I cannot solve unless I re-create everything from scratch.