Repeat Panel has title of measurement name and not variable name

Hi

I have a repeating (gauge) panel with the template variable $foovar and the Display Name defined as $varfoo

Query is `SELECT LAST(value) FROM dxdata where foo=‘$foovar’

About a third of the values for $varfoo always give a display of dxdata.last
If there is no LAST() in the query, the the Name displayed is odly dxdata.value

The output of the query for the working and properly displayed values and those with this error has no difference that I can see as relevant.

Is there a trick or an actual fix for this.

Thanks
E