Remove last point when querying

Hi. I’ve tried to drop the last data point as recommended in [INFLUXQL] Drop the Last Data Point with a combination of limit() and count() function: |> limit(n: (count()-1)) but i get an error:

 error @7:16-7:23: missing required argument tables error @7:24-7:25: expected stream[A] but found int error @7:16-7:25: stream[A] is not Subtractable

How I can drop the last point with self-calculation of a number of records, so I don’t have to enter the number of points manually?

Best regards,
Nikodem

Hello @Nikodemski2002,
Yes you can. I wish it was as easy as what you’ve described. Unfortunately you have to do the following instead

data = from...
range...
filter...

n_records = (data
|> count()
|> findRecord(
        fn: (key) => true,
        idx: 0,
    ))._value 

data |> limit(n: n_records) 

Lmk if you have any further questions.

Thanks @Anaisdg it works as should.

1 Like

@Nikodemski2002,
Sure thing! Btw what are you using InfluxDB for? I’m curious to learn about your project.
Thanks