Skip to main content
Question

How Can I obtain the n-th value in the a list?

  • August 27, 2024
  • 1 reply
  • 10 views

Forum|alt.badge.img+6

If FIRST(column) would return the first element and LAST(column) the last one, I would like to obtain the n-th element of that list. There isn't a straightforward function to do that but is there a way?

1 reply

mateusz.dudek14
Level 11
Forum|alt.badge.img+11

Hi,

 

Just use INDEX_ORDER() function. Sort by specific column, and then just filter it by INDEX_ORDER value.

F.e. if you want to add values only form the 3rd element and 5th element of the list use:

SUM(CASE WHEN INDEX_ORDER (TABLE.COLUMN, ORDER BY(TABLE.COLUMN ASC) = 3 OR INDEX_ORDER (TABLE.COLUMN, ORDER BY (TABLE>COLUMN ASC)) = 5 THEN TABLE>COLUMN ELSE 0 END)

 

Let us know if that's the thing you needed - if actually helped, mark as best answer.

 

Best Regards,

Mateusz Dudek