Ok, so this is your more or less expected result:
With flux it is pretty easy:
|> map(fn: (r) => {
tmp_ = regexp.replaceAllString(r: /^ILO/, t: "", v: regexp.replaceAllString(r: /^ILO0/, t: "0.", v: r["txt"]))
num = regexp.replaceAllString(r: /_test$/, t: "", v: tmp_)
return { r with num: num }
})
Not sure about InfluxQL though.
As for using variables in transformations, it is possible:
Just enable necessary feature toggle: