Get the latest record from the measurement table

I want to get the latest record from the measurement table and to update the one column value based the tag condition using asp.net web api.

Hello @udaya_kumar,
Maybe something like this?

import "experimental/array"

original = array.from(rows: [{_time: 2021-01-01T00:00:00Z, _value: 1.0},
                             {_time: 2021-01-02T00:00:00Z, _value: 3.0},
                             {_time: 2021-01-03T00:00:00Z, _value: 10.0}])

// original 
// |> yield(name: "original")

getValue = original 
|> last()
|> tableFind(fn: (key) => true)
|> getRecord(idx: 0)

original
 |> map(fn: (r) => ({
    r with
    level:
      if r._value >= getValue._value then "foo"
      else "bar"
    })
  )

You can copy and paste this query and try it for yourself. If it’s not meeting your needs, and
to better help you, can you please provide some input data and expected output data? Thanks