Selecting multiple fields using flux

i am trying to select more than one field using flux. i do want to use regex as i have to select around 10 fields having different names.

the equivalent query in influx is as follows:
select field1, field_two, field_3 from meas group by tag1 order by time desc limit 1

after going through the documentation i can select one field and tag like below:

dataset = from(bucket:“db/rp”)
|> range(start: -3h)
|> limit(n:1)
|> filter(fn: ® =>
r._measurement == “meas” and
r._field == “netPnl”
)
|> group(columns: [“tag1”, “tag_two”])

|> yield()

i am not able to find a way to implement my select query…
please help…

you need to use a field regex then pivot the data:

dataset = from(bucket:“db/rp”)
|> range(start: -3h)
|> limit(n:1)
|> filter(fn: ® =>
r._measurement == “meas” and
r._field =~ /tag.*/
)
|> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: “_value”)
|> group(columns: [“tag1”, “tag_two”])
|> yield()

but how would this select the field i want?
i want to select two fields pnl and netPnl and group them using tag strat, server

put the fields that you want in the regex:

r._field =~ /^pnl$|^netPnl$/

or don’t use a regex and just use normal conditional:

(r._field == “pnl” or r._field == “netPnl”)

this will pull in your fields as field/value pair rows, which is why you pivot to put it back into the customary table format

brian