Retrieve last N records from a table

Aylas
New Member

Good morning, I have a table with multiple records, from which I want to retrieve the last N records, these in turn must belong to the same point.

IdReg__|Cod.Punto|pH__|Od|NTU โ€ฆ
2210
|PTO001__|7.45|5.41|12.1
2211
|PTO002
_|8.15|7.97|7.88
2212
|PTO003
_|7.54|6.11|9.12
2213
|PTO001
_|6.78|4.18|7.45
2214
|PTO002
_|8.24|7.91|4.66
2215
|PTO003
_|9.11|7.48|9.44
2216
|PTO001
_|4.47|4.91|8.12
2217
|PTO002
_|6.54|6.88|10.4
2218
|PTO003
_|6.45|5.41|12.4
2219
|PTO001
_|4.47|4.91|8.12
2220
|PTO002
_|6.54|6.88|10.4
2221
|PTO003
_|6.45|_5.41|___12.4

What would be the method to obtain the last 10 records of the table that correspond to โ€œPTO001โ€?

Solved Solved
0 10 331
1 ACCEPTED SOLUTION

Wait, you are on a row filter condition.
The expression was for giving a list of items, depending on a specific row.

From what I see, this would rather be:

IN([_THISROW],
TOP(
  ORDERBY(
    FILTER("Registro CAR",
      [Cod. Estaciรณn]="CA-07"
    ),
  [_ROWNUMBER],true)
  ,10
)
)

View solution in original post

10 REPLIES 10

Aurelien
Google Developer Expert
Google Developer Expert

Hi @Aylas

Welcome to the community !

It will be a mix with TOP and ORDERBY.
Depending on your table structure, you may want to use a SELECT or FILTER as well.
For reference:

Thanks for the answer, could you give me a suggestion on how to use the mentioned expressions?

Yes.

Does that gives you a clue ?

or

Otherwise, please share your table structure (with screenshot)

I want to do the filtering through โ€œCod. Estaciรณnโ€, the primary key is โ€œNยฐ Muestraโ€

Thanks for the screenshot.

What about that ?

TOP(
  ORDERBY(
    FILTER("Registro CAR",
      [Cod. Estaciรณn]="CA-07"
    ),
  [_ROWNUMBER],true)
  ,10
)

Edit: some comma removed

Thank you very much, for your consideration, I attach some screenshots, I did not manage to make the sentence run.


Wait, you are on a row filter condition.
The expression was for giving a list of items, depending on a specific row.

From what I see, this would rather be:

IN([_THISROW],
TOP(
  ORDERBY(
    FILTER("Registro CAR",
      [Cod. Estaciรณn]="CA-07"
    ),
  [_ROWNUMBER],true)
  ,10
)
)

Perfect, thank you very much, it worked like a charm.

Steve
Platinum 4
Platinum 4

There is an example of this in the TOP() help document.

Thank you @Steve for highlighting this.

I assumed it was not fitting enough to @Aylas 's case so I took time to make it fit.

Top Labels in this Space